Skip to content

[security-fix] Suppress false positive G101 hardcoded credentials alert (Alert #433)#8326

Merged
pelikhan merged 1 commit intomainfrom
main-f6476bc411473431
Dec 31, 2025
Merged

[security-fix] Suppress false positive G101 hardcoded credentials alert (Alert #433)#8326
pelikhan merged 1 commit intomainfrom
main-f6476bc411473431

Conversation

@github-actions
Copy link
Contributor

Security Fix: Suppress False Positive G101 Alert

Alert Number: #433
Severity: High (False Positive)
Rule: G101 - Potential hardcoded credentials
Tool: gosec (Golang security checks)
Location: pkg/workflow/safe_outputs_steps.go:81

Vulnerability Description

Gosec G101 rule flagged line 81 in safe_outputs_steps.go as containing a potential hardcoded credential:

token = "${{ secrets.COPILOT_TOKEN || secrets.GITHUB_TOKEN }}"

This is a FALSE POSITIVE. The code is not storing an actual hardcoded credential - it's building a GitHub Actions workflow YAML string that references secrets using GitHub Actions expression syntax. The string will be rendered in the generated workflow file and evaluated at runtime by GitHub Actions to retrieve the actual secret values.

Why This Is A False Positive

  1. No actual credential stored: The string contains placeholders, not actual secret values
  2. GitHub Actions expression syntax: ${{ secrets.* }} is the standard way to reference secrets in GitHub Actions workflows
  3. Runtime evaluation: The secrets are resolved at workflow execution time, not at compile time
  4. Code generation context: This function generates YAML content for workflow files, not executable code that handles secrets

Fix Applied

Added a #nosec G101 comment with explanation to suppress the false positive alert:

if useCopilotToken {
    // #nosec G101 -- This is not a hardcoded credential, it's a GitHub Actions expression template
    // that will be rendered in the workflow YAML to reference secrets at runtime
    token = "${{ secrets.COPILOT_TOKEN || secrets.GITHUB_TOKEN }}"
}

This approach:

  • Documents the intentional use: Makes it clear this is workflow template code
  • Explains the false positive: Helps future maintainers understand why the suppression is needed
  • Follows Go security best practices: Using #nosec directives for known false positives is the standard approach

Security Best Practices

Proper use of #nosec directive: Includes explanatory comment as recommended by gosec
No actual security risk: The code correctly uses GitHub Actions expression syntax
Maintains security scanner coverage: Other G101 alerts will still be detected
Zero functional impact: No code behavior changes

Testing

Build succeeded: go build ./pkg/workflow/... passes without errors
No breaking changes: Workflow generation continues to work correctly
Comment-only change: No runtime behavior affected

Impact Assessment

Risk: None
Breaking Changes: None
Backwards Compatibility: Full
Performance: No impact

The change only adds a comment to suppress a false positive security alert. The actual code behavior is unchanged.

Why This Fix Is Important

  1. Reduces alert noise: Eliminates a high-severity false positive that could mask real issues
  2. Improves signal-to-noise ratio: Helps security teams focus on actual vulnerabilities
  3. Documents intent: Makes it clear this is intentional template code
  4. Standard practice: Using #nosec for false positives is the recommended approach in Go security scanning

Files Modified

  • pkg/workflow/safe_outputs_steps.go:
    • Lines 81-83: Added #nosec G101 comment with explanation

References

AI generated by Security Fix PR

Added #nosec G101 comment to suppress false positive alert in
safe_outputs_steps.go line 81. The flagged line contains a GitHub Actions
expression template string that references secrets at runtime, not a
hardcoded credential.

Alert: https://github.com/githubnext/gh-aw/security/code-scanning/433

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@pelikhan pelikhan marked this pull request as ready for review December 31, 2025 16:33
@pelikhan pelikhan merged commit 045ac42 into main Dec 31, 2025
4 checks passed
@pelikhan pelikhan deleted the main-f6476bc411473431 branch December 31, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant