Skip to content

[log] Add debug logging to internal/hmacutil - #12192

Merged
lpcox merged 2 commits into
mainfrom
log-enhance-hmacutil-c55481b009c9940d
Aug 31, 2026
Merged

[log] Add debug logging to internal/hmacutil#12192
lpcox merged 2 commits into
mainfrom
log-enhance-hmacutil-c55481b009c9940d

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Adds debug logging to internal/hmacutil/hmacutil.go, which previously had no logging infrastructure at all.

Changes

  • Added a file-scoped logger var log = logger.ForFile() (namespace hmacutil:hmacutil)
  • Sign: logs key/message lengths on entry and signature length on completion
  • Verify: logs key/message/MAC lengths on entry and whether verification succeeded or failed

No side effects were introduced in log arguments (only length/boolean values are logged, never key or message contents, to avoid leaking sensitive data).

Validation

  • go build -o awmg . — succeeds
  • go vet ./internal/hmacutil — clean
  • go test ./internal/hmacutil — passes

Enable with DEBUG=hmacutil:* ./awmg --config config.toml.

Generated by Go Logger Enhancement · copilot · auto · 41.2 AIC · ⊞ 13K ·

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Aug 30, 2026
@lpcox
lpcox marked this pull request as ready for review August 31, 2026 14:43
Copilot AI balanced review requested due to automatic review settings August 31, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new logging behavior lacks tests, and the logger name violates the repository’s naming convention.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds safe debug tracing to HMAC signing and verification.

Changes:

  • Adds a file-scoped logger.
  • Logs input lengths and verification outcomes without sensitive contents.
File summaries
File Description
internal/hmacutil/hmacutil.go Adds debug logging around HMAC operations.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/hmacutil/hmacutil.go Outdated
"github.com/github/gh-aw-mcpg/internal/logger"
)

var log = logger.ForFile()
Comment thread internal/hmacutil/hmacutil.go Outdated

// Sign returns the HMAC-SHA256 signature for message using key.
func Sign(key []byte, message string) []byte {
log.Printf("Signing message: keyLen=%d, messageLen=%d", len(key), len(message))
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@lpcox

lpcox commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in 3210ea9: renamed the logger to logHMACUtil and added enabled-DEBUG coverage for signing plus successful and failed verification, including assertions that key and message contents are not logged.

Copilot AI requested a review from lpcox August 31, 2026 15:04
@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — gVisor

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: gVisor (runsc) kernel-level isolation

Part Surface Op Result Expected Status
A1 MCP list_issues (3) 3 issues returned ALLOWED
A2 MCP list_pull_requests (3) 3 PRs returned ALLOWED
A3 MCP get_file_contents README.md content returned ALLOWED
A4 MCP list_commits (3) 3 commits returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 7 tools absent from catalog (23 read-only tools exposed) BLOCKED ⚠️
C1 CLI list_issues via github CLI 3 issues returned ALLOWED
C2 CLI get_file_contents README.md via github CLI content returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) gh not authenticated (no GH_TOKEN) BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh not authenticated (no GH_TOKEN) BLOCKED ⚠️

Overall: INCONCLUSIVE

Notes:

  • ⚠️ Part B: All 7 write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request, and reaction variant) are absent from the exposed MCP tool catalog. The backend runs with GITHUB_READ_ONLY=1, so only 23 read-only tools are registered. This confirms the gh-aw framework's defense-in-depth guarantee but does not exercise mcpg's own DIFC/guard enforcement layer independently — tool calls never reach a write-capable backend. Recorded as INCONCLUSIVE per methodology.
  • ⚠️ Parts D/E: gh CLI is not authenticated in this environment (gh auth status → "not logged into any GitHub hosts", no GH_TOKEN). Token-scope boundary for REST/GraphQL writes cannot be validated. All D/E rows are INCONCLUSIVE, not PASS/FAIL.
  • Part A and C reads all succeeded as expected.
  • No write succeeded or leaked through any surface.

References: §33405863846

🔒 mcpg read-only stress (gVisor runtime) by Read-Only Stress: gVisor runtime

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP list_issues 3 issues returned ALLOWED
A MCP list_pull_requests 2 PRs returned ALLOWED
A MCP get_file_contents (README.md) content returned ALLOWED
A MCP list_commits 3 commits returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 7 tools absent from catalog BLOCKED ⚠️
C CLI list_issues 3 issues returned ALLOWED
C CLI get_file_contents (README.md) content returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) gh unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Notes:

  • Part B: All 7 write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) were absent from the MCP tool catalog. The backend runs with GITHUB_READ_ONLY=1 per gh-aw framework design, so write tools are never registered. This confirms the backend defense-in-depth guarantee but cannot independently confirm gateway-level DIFC/guard enforcement. No write leaked.
  • Parts D & E: gh is not authenticated in this workflow (GH_TOKEN not set). All CLI write attempts were skipped; token-scope boundary cannot be validated in this run.
  • No write succeeded in any part. INCONCLUSIVE reflects methodology gaps only, not any enforcement failure.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — docker-sbx

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: docker-sbx (KVM-isolated microVM)

Part Surface Op Result Expected Status
A MCP list_issues 3 issues returned ALLOWED
A MCP list_pull_requests 3 PRs returned ALLOWED
A MCP get_file_contents (README.md) content returned ALLOWED
A MCP list_commits 3 commits returned ALLOWED
B MCP add_issue_comment (reaction) unknown tool — ABSENT BLOCKED ⚠️
B MCP star_repository unknown tool — ABSENT BLOCKED ⚠️
B MCP issue_write (create) unknown tool — ABSENT BLOCKED ⚠️
B MCP add_issue_comment (body) unknown tool — ABSENT BLOCKED ⚠️
B MCP create_branch unknown tool — ABSENT BLOCKED ⚠️
B MCP create_or_update_file unknown tool — ABSENT BLOCKED ⚠️
B MCP create_pull_request unknown tool — ABSENT BLOCKED ⚠️
C CLI list_issues (github CLI) 3 issues returned ALLOWED
C CLI get_file_contents (github CLI) content returned ALLOWED
D CLI REST reaction POST 401 Bad credentials BLOCKED ⚠️
D CLI REST star PUT 401 Bad credentials BLOCKED ⚠️
D CLI issue create (gh CLI) 401 Bad credentials BLOCKED ⚠️
D CLI issue create (REST) 401 Bad credentials BLOCKED ⚠️
D CLI comment POST 401 Bad credentials BLOCKED ⚠️
D CLI file write PUT 401 Bad credentials BLOCKED ⚠️
E CLI GraphQL addReaction mutation 401 Bad credentials BLOCKED ⚠️
E CLI GraphQL addStar mutation 401 Bad credentials BLOCKED ⚠️
E CLI GraphQL createIssue mutation 401 Bad credentials BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B (all 7 rows): All MCP write tools were ABSENT from the backend tool catalog (Error [-32602]: unknown tool). This confirms GITHUB_READ_ONLY=1 is active in the gh-aw framework — write tools are never registered by the backend. This is expected defence-in-depth, but gateway-level (DIFC/guard) enforcement could not be independently confirmed since no write-capable tool call reached the gateway proxy layer. This is a structural limitation of the test methodology as documented in the test plan.

⚠️ Parts D & E (all 9 rows): gh CLI token (GH_TOKEN) returned 401 Bad credentials for all write attempts. Authentication was invalid in this environment — the 401s prove the token has no write access, but do not independently confirm gateway-level REST/GraphQL write filtering. All Part D/E rows are INCONCLUSIVE (not FAIL), consistent with test plan guidance.

No writes leaked through on any surface. The overall enforcement guarantee holds, but gateway-specific (DIFC) enforcement was not directly exercised in this run due to backend read-only mode and invalid gh credentials.

🔒 mcpg read-only stress (docker-sbx runtime) by Read-Only Stress: docker-sbx runtime

@lpcox
lpcox merged commit 2e1dc29 into main Aug 31, 2026
37 checks passed
@lpcox
lpcox deleted the log-enhance-hmacutil-c55481b009c9940d branch August 31, 2026 15:31
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.

3 participants