feat: Implement GitHub Action outputs and golden tests#12
Merged
pfrederiksen merged 2 commits intomainfrom Jan 17, 2026
Merged
Conversation
Add GitHub Actions integration with has-changes and diff-output outputs. Convert output format tests to use golden files for better maintainability. Changes: - Add writeGitHubOutputs() to write GitHub Actions outputs - Detect GITHUB_OUTPUT env var and write outputs in correct format - Convert TestGenerateStat to golden file tests (4 test cases) - Convert TestGenerateSideBySide to golden file tests (5 test cases) - Convert TestGenerateGitDiff to golden file tests (5 test cases) - Add comprehensive tests for GitHub Actions output functionality - Fix variable redeclaration in compareFiles() Addresses PR review comments from #11: - Issue 3: GitHub Action outputs now fully implemented - Issue 4: Golden tests added for all new output formats Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code ReviewI found 1 issue that should be addressed: Heredoc Delimiter Injection Vulnerability in GitHub Actions OutputFile: The heredoc format uses a fixed
For example, a config file containing: value: |
Some text
EOF
injected-output=maliciousRecommended fix: Use a randomized delimiter that cannot appear in the content: delimiter := fmt.Sprintf("ghadelimiter_%d", rand.Int63())
if _, err := fmt.Fprintf(f, "diff-output<<%s\n%s\n%s\n", delimiter, diffOutput, delimiter); err \!= nil {
return err
}See GitHub's documentation on multiline strings for more details. Reference: configdiff/cmd/configdiff/compare.go Lines 282 to 285 in e8f3784 |
Fix heredoc delimiter injection vulnerability by using a cryptographically random delimiter instead of fixed "EOF" string. Security issue: A config file containing "EOF" on its own line could prematurely terminate the heredoc and potentially inject arbitrary GitHub Actions workflow commands. Changes: - Generate random 16-byte delimiter prefixed with "ghadelimiter_" - Update tests to verify random delimiter format - Add test case specifically for EOF injection attack - Add reference to GitHub Actions multiline string documentation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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
This PR addresses the remaining issues from PR #11 review:
Changes
GitHub Actions Integration
writeGitHubOutputs()function to write outputs in GitHub Actions formatGITHUB_OUTPUTenvironment variable automaticallyhas-changesas boolean (true/false)diff-outputusing heredoc format for multiline contentGolden Tests
TestGenerateStatto use golden files (4 test cases)TestGenerateSideBySideto use golden files (5 test cases)TestGenerateGitDiffto use golden files (5 test cases)testdata/report/-updateflag to regenerate golden filesBug Fixes
compareFiles()Test Results
All tests passing with good coverage:
cmd/configdiff: 67.7% coveragereport: 90.9% coverageRelated
Addresses review comments from #11 before merging and releasing v0.3.0.
🤖 Generated with Claude Code