Repository navigation
feat(config): site environment ingress contract & configuration sanitizer - #38
Merged
Merged
Conversation
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.
Contract & Sanitization Breakdown: Site Configuration & Environment Ingress
1. Input Contract Specifications
Static site generation processes rely on environment variables for URL canonicalization, port binding, build flags, and output routing. Unsanitized ingress allows path traversal, port privilege escalation, and credential exposure in logs.
Ingress Field Validation Schema
site_urlBUILDSITE_URL,SITE_URLportBUILDSITE_PORT,PORTenvironmentBUILDSITE_ENV,ENV,NODE_ENV{production, staging, development, testing}debugBUILDSITE_DEBUG,DEBUG1/true/yes/onTrue,0/false/no/offFalseoutput_dirBUILDSITE_OUTPUT_DIR,OUTPUT_DIR..traversal, leading/, drive roots, null bytesapi_keyBUILDSITE_API_KEY,API_KEYak_l...cdef)2. Security Defense Mechanics
https://user:pass@host/) by raisingContractValidationError.allow_privileged_ports=True.../components across both POSIX and Windows separators, preventing builds from overwriting system files.to_safe_dict()automatically redacts API keys and secrets, preventing credential leakage in stdout/CI logs.3. Test Matrix & Verification
test_parse_bool_flag_truthy_and_falsy: Asserts parsing across true/false variations and rejection of invalid types/strings.test_sanitize_site_url_valid_and_normalization: Verifies root trailing slash removal, default port scrubbing, and default fallback.test_sanitize_site_url_rejections: Confirms rejection of non-http schemes, userinfo credentials, and null-byte injection.test_sanitize_port_bounds_and_privileged: Validates port boundary constraints and unprivileged floor enforcement.test_sanitize_environment_name: Verifies environment tier normalization and error raising on unrecognized environments.test_sanitize_path_segment_traversal_defense: Verifies rejection of relative path escapes and absolute root paths.test_site_environment_contract_from_dict: Confirms full contract instantiation, secret masking, and safe serialization.