Skip to content

Add compilation warning for id-token: write permission#15026

Merged
pelikhan merged 3 commits intomainfrom
copilot/add-compilation-warning-id-token
Feb 11, 2026
Merged

Add compilation warning for id-token: write permission#15026
pelikhan merged 3 commits intomainfrom
copilot/add-compilation-warning-id-token

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Workflows using id-token: write permission now emit a compilation warning to inform developers about OIDC authentication security considerations.

Changes

  • Compiler validation (pkg/workflow/compiler.go): Added detection for id-token: write permission after GitHub MCP toolsets validation
  • Integration tests (pkg/workflow/idtoken_write_warning_test.go): Coverage for warning presence/absence across permission combinations

Example Output

When compiling a workflow with id-token: write:

---
permissions:
  contents: read
  id-token: write
---

Produces:

workflow.md:1:1: warning: This workflow grants id-token: write permission
OIDC tokens can authenticate to cloud providers (AWS, Azure, GCP).
Ensure proper audience validation and trust policies are configured.

The warning uses the standard compiler message format and increments the warning counter.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add compilation warning for id-token write permission Add compilation warning for id-token: write permission Feb 11, 2026
Copilot AI requested a review from pelikhan February 11, 2026 23:28
@pelikhan pelikhan marked this pull request as ready for review February 11, 2026 23:29
Copilot AI review requested due to automatic review settings February 11, 2026 23:29
@pelikhan pelikhan merged commit c79b6f0 into main Feb 11, 2026
57 checks passed
@pelikhan pelikhan deleted the copilot/add-compilation-warning-id-token branch February 11, 2026 23:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a compiler warning when a workflow frontmatter grants permissions: id-token: write, to highlight OIDC security considerations during workflow compilation.

Changes:

  • Detect id-token: write in compiled workflow permissions and emit a formatted compiler warning while incrementing warning count.
  • Add integration tests validating warning presence/absence across permission combinations and verifying message contents.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
pkg/workflow/compiler.go Adds detection of id-token: write and emits a compiler warning + increments warning count.
pkg/workflow/idtoken_write_warning_test.go Introduces integration tests that compile sample workflows and assert warning output/count behavior.
Comments suppressed due to low confidence (2)

pkg/workflow/idtoken_write_warning_test.go:200

  • os.Pipe() errors are ignored here (r, w, _ := os.Pipe()), which can lead to nil pipes and misleading test failures. Handle the returned error and fail the test if pipe creation fails.
	r, w, _ := os.Pipe()
	os.Stderr = w

pkg/workflow/idtoken_write_warning_test.go:210

  • The read end of the pipe (r) is never closed and io.Copy errors are ignored. Close r and check the io.Copy return error to avoid FD leaks and silent read failures.
	var buf bytes.Buffer
	io.Copy(&buf, r)
	stderrOutput := buf.String()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +265 to +267
warningMsg := `This workflow grants id-token: write permission
OIDC tokens can authenticate to cloud providers (AWS, Azure, GCP).
Ensure proper audience validation and trust policies are configured.`
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The raw string literal for warningMsg includes leading spaces on the 2nd/3rd lines due to code indentation, which will render as extra indentation in the warning output and won’t match the example output in the PR description. Consider left-aligning the message text (or trimming indentation) so the emitted warning is clean and consistent.

Suggested change
warningMsg := `This workflow grants id-token: write permission
OIDC tokens can authenticate to cloud providers (AWS, Azure, GCP).
Ensure proper audience validation and trust policies are configured.`
warningMsg := "This workflow grants id-token: write permission\n" +
"OIDC tokens can authenticate to cloud providers (AWS, Azure, GCP).\n" +
"Ensure proper audience validation and trust policies are configured."

Copilot uses AI. Check for mistakes.
Comment on lines +260 to +262
if workflowData.Permissions != "" {
permissions := NewPermissionsParser(workflowData.Permissions).ToPermissions()
if permissions != nil {
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

NewPermissionsParser(workflowData.Permissions).ToPermissions() is invoked again here even though permissions were already parsed earlier in this function for MCP toolset validation. Consider parsing once and reusing the result to avoid duplicated logic and keep warning/validation behavior consistent.

Copilot uses AI. Check for mistakes.

// Capture stderr to check for warnings
oldStderr := os.Stderr
r, w, _ := os.Pipe()
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

os.Pipe() errors are ignored here (r, w, _ := os.Pipe()), which can lead to nil pipes and misleading test failures. Handle the returned error and fail the test if pipe creation fails.

This issue also appears on line 198 of the same file.

Suggested change
r, w, _ := os.Pipe()
r, w, pipeErr := os.Pipe()
if pipeErr != nil {
t.Fatalf("failed to create stderr pipe: %v", pipeErr)
}

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +129
r, w, _ := os.Pipe()
os.Stderr = w

compiler := NewCompiler()
compiler.SetStrictMode(false)
err := compiler.CompileWorkflow(testFile)

// Restore stderr
w.Close()
os.Stderr = oldStderr
var buf bytes.Buffer
io.Copy(&buf, r)
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

The read end of the pipe (r) is never closed and io.Copy errors are ignored. Close r (typically with defer r.Close() after successful os.Pipe()) and check the io.Copy return error to avoid FD leaks and silent read failures in CI.

This issue also appears on line 208 of the same file.

Suggested change
r, w, _ := os.Pipe()
os.Stderr = w
compiler := NewCompiler()
compiler.SetStrictMode(false)
err := compiler.CompileWorkflow(testFile)
// Restore stderr
w.Close()
os.Stderr = oldStderr
var buf bytes.Buffer
io.Copy(&buf, r)
r, w, err := os.Pipe()
if err != nil {
t.Fatalf("failed to create stderr pipe: %v", err)
}
defer r.Close()
os.Stderr = w
compiler := NewCompiler()
compiler.SetStrictMode(false)
err = compiler.CompileWorkflow(testFile)
// Restore stderr
w.Close()
os.Stderr = oldStderr
var buf bytes.Buffer
if _, copyErr := io.Copy(&buf, r); copyErr != nil {
t.Fatalf("failed to read from stderr pipe: %v", copyErr)
}

Copilot uses AI. Check for mistakes.
Comment on lines +258 to +260
// Emit warning if id-token: write permission is detected
log.Printf("Checking for id-token: write permission")
if workflowData.Permissions != "" {
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

log.Printf("Checking for id-token: write permission") will be written to stderr by the standard logger, and it contains the exact substring id-token: write. That makes stderr-based warning detection (including the new tests) flaky and also pollutes compiler output. Please remove this log line or gate it behind an explicit verbose/debug flag and avoid emitting id-token: write verbatim in logs.

See below for a potential fix:

						fmt.Fprintln(os.Stderr, formatCompilerMessage(markdownPath, "warning", message))
						c.IncrementWarningCount()
					}
				}
			}
		}
	}

	// Emit warning if id-token: write permission is detected

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants