Add scan-config command to extract env placeholders from config files#7
Merged
Merged
Conversation
Adds a new `envguard scan-config` command that extracts ${VAR} and
${VAR:default} placeholders from YAML and .properties config files,
reporting required and optional variables separately.
New internal/configscan package with:
- extract.go: shared regex-based placeholder extraction
- yaml.go: YAML AST traversal using gopkg.in/yaml.v3
- props.go: line-by-line .properties parser
- types.go: Placeholder and ScanResult types
Command flags: --files, --format, --local, --example, --strict, --json, --quiet
https://claude.ai/code/session_011LtAmNkYuy2HPHQwL8dZyP
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.
Summary
Adds a new
scan-configcommand that extracts environment variable placeholders (${VAR}and${VAR:default}) from Spring Boot and Quarkus configuration files (YAML and.propertiesformats). The command distinguishes between required variables (no default) and optional variables (with defaults), and can validate that all required variables are defined in local.envor.env.examplefiles.Key Changes
New command
scan-config(cmd/scan_config.go):.propertiesconfig files for${VAR}and${VAR:default}placeholders.envparser to compare against local/example files--strictmode to exit with error if required variables are missing--files,--format,--local,--example,--strict,--json,--quietNew
internal/configscanpackage with modular extraction logic:types.go: CorePlaceholderandScanResulttypesextract.go: Regex-based placeholder extraction with deduplicationyaml.go: YAML file parsing with recursive tree walking to build key pathsprops.go: Java.propertiesfile parsingTest suite covering:
.propertiesfile parsing with comments and edge casesDocumentation in README with usage examples, flag descriptions, and sample config formats
Integration: Registered new command in
cmd/root.goand addedgopkg.in/yaml.v3dependencyImplementation Details
[A-Z_][A-Z0-9_]*) to avoid false positivesspring.datasource.url) and array indices (e.g.,servers.0.host)https://claude.ai/code/session_011LtAmNkYuy2HPHQwL8dZyP