SecurityHeaders middleware + fix availability calculation - #183
Open
bakhterets wants to merge 3 commits into
Open
SecurityHeaders middleware + fix availability calculation#183bakhterets wants to merge 3 commits into
bakhterets wants to merge 3 commits into
Conversation
- Remove early nil return for empty incidents list - Add nil check for inc.Impact before dereferencing - Rewrite unit tests with deterministic cases (100%, 50%, 20%, 0%) - Make integration test self-contained with relative dates Cherry-picked from fix/availability (86d6507) with additional stabilization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security Headers
Added
SecurityHeadersmiddleware applied to all routes, setting protective HTTP headers:X-Content-Type-OptionsnosniffX-Frame-OptionsDENYContent-Security-Policydefault-src 'none'X-XSS-Protection1; mode=blockStrict-Transport-Securitymax-age=31536000; includeSubDomainsAvailability Fix
Fixed two bugs in
calculateAvailability()that causedTestV2GetComponentsAvailabilityto fail:inc.Impactwithout nil checknil, nilinstead of a valid 12-month array when component had no incidentsCode changes (
internal/api/v2/v2.go):return nil, nilfor empty incidents — always returns full 12-month availabilityinc.Impact == nilguard before dereferencingUnit tests (
internal/api/v2/v2_test.go):TestCalculateAvailabilitywith deterministic cases (100%, 50%, 20%, 0%)assert.InDeltafor stable floating-point comparisonIntegration tests (
tests/v2_test.go):TestV2GetComponentsAvailabilityself-contained (creates its own component)