-
Notifications
You must be signed in to change notification settings - Fork 30
Add structured metadata fields to findings for programmatic access #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adds new fields to FindingMeta for library users who need machine-readable access to security-relevant data without parsing human-readable strings: - injection_sources: Array of specific expressions being injected - lotp_tool: Living Off The Pipeline build tool (npm, pip, make, etc.) - lotp_action: LOTP GitHub Action identifier - referenced_secrets: Secrets referenced in the job (excludes GITHUB_TOKEN) The referenced_secrets field is automatically extracted when rules pass the _job field, supporting dot notation (secrets.FOO) and bracket notation (secrets['FOO'] and secrets["FOO"]). Benchmark (Apple M4 Pro): | Version | ns/op | B/op | allocs/op | |---------|-----------|-----------|-----------| | Before | 10971339 | 7149084 | 132787 | | After | 12059356 | 7858242 | 148422 | | Delta | +9.9% | +9.9% | +11.8% | Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds structured metadata fields to security findings, enabling programmatic access to security-relevant information without parsing human-readable text. The implementation includes new fields for injection sources, LOTP (Living Off The Pipeline) tools/actions, and referenced secrets.
Changes:
- Added four new structured metadata fields to
FindingMeta:InjectionSources,LOTPTool,LOTPAction, andReferencedSecrets - Implemented Rego helper functions to extract and sort injection sources and secrets from GitHub Actions expressions
- Updated all existing test expectations to include the new structured fields with appropriate values
- Added comprehensive test workflow and test case to verify the new fields are populated correctly
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| results/results.go | Adds four new structured metadata fields to FindingMeta struct with clear documentation |
| opa/rego/poutine/utils.rego | Implements helper functions to extract secrets from GitHub Actions expressions using regex patterns for dot and bracket notation |
| opa/rego/poutine.rego | Modifies finding() function to automatically extract referenced_secrets from _job field for GitHub Actions findings |
| opa/rego/rules/injection.rego | Adds injection_sources field (sorted array) and _job field to GitHub Actions injection findings |
| opa/rego/rules/untrusted_checkout_exec.rego | Adds lotp_tool/lotp_action fields and _job field to GitHub Actions untrusted checkout exec findings, also adds job ID to finding metadata |
| scanner/testdata/.github/workflows/test_new_fields.yml | New test workflow with injection vulnerabilities and LOTP scenarios to validate structured metadata extraction |
| scanner/inventory_test.go | Updates all test expectations with new structured fields and adds TestStructuredFindingFields to validate the implementation |
| scanner/inventory_scanner_test.go | Adds new test workflow to the expected workflow list |
| docs/content/en/structured-finding-metadata.md | Comprehensive documentation explaining the new fields, usage examples, and backward compatibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes perfsprint linter warning by replacing fmt.Sprintf("%x", ...) with
hex.EncodeToString which is more performant.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes testifylint warning by using require.NoError instead of assert.NoError for error checking in TestStructuredFindingFields. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
injection_sources,lotp_tool,lotp_action,referenced_secrets) to findings, enabling programmatic access to security-relevant information without parsing human-readable textpoutine/utils.regoto extract and sort injection sources from tainted expressionsreferenced_secretsfield is automatically extracted when rules pass the_jobfield, supporting dot notation (secrets.FOO) and bracket notation (secrets['FOO']andsecrets["FOO"])Benchmark (Apple M4 Pro)
Test plan
test_new_fields.yml) to verify structured metadata extractionTestStructuredFindingFieldstest with assertions for new fields🤖 Generated with Claude Code