GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Warn if a private registry configuration uses a PAT, but has no username by mbg · Pull Request #3422 · github/codeql-action

Conversation

@mbg

@mbg mbg commented Jan 24, 2026

Copy link
Copy Markdown
Member

To authenticate using a PAT, the corresponding username is required. Using a PAT on its own, without the corresponding username, does not work.

This PR modifies the start-proxy action to check whether a configuration seems to use a GitHub PAT without a username and issue a warning in that case.

In the process, I also taught the artifact scanner about fine-grained tokens (start with github_pat_ and are longer than classic PATs) and extended the tests there.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Which use cases does this change impact?

Workflow types:

  • Managed - Impacts users with dynamic workflows (Default Setup, CCR, ...).

Products:

  • Code Scanning - The changes impact analyses when analysis-kinds: code-scanning.
  • Code Quality - The changes impact analyses when analysis-kinds: code-quality.

Environments:

  • Dotcom - Impacts CodeQL workflows on github.com and/or GitHub Enterprise Cloud with Data Residency.
  • GHES - Impacts CodeQL workflows on GitHub Enterprise Server.

How did/will you validate this change?

  • Test repository - This change will be tested on a test repository before merging.
  • Unit tests - I am depending on unit test coverage (i.e. tests in .test.ts files).
  • End-to-end tests - I am depending on PR checks (i.e. tests in pr-checks).

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Rollback - Change can only be disabled by rolling back the release or releasing a new version with a fix.

How will you know if something goes wrong after this change is released?

  • Telemetry - I rely on existing telemetry or have made changes to the telemetry.
    • Dashboards - I will watch relevant dashboards for issues after the release. Consider whether this requires this change to be released at a particular time rather than as part of a regular release.
    • Alerts - New or existing monitors will trip if something goes wrong with this change.

Are there any special considerations for merging or releasing this change?

  • No special considerations - This change can be merged at any time.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mbg added 6 commits January 24, 2026 11:52
@mbg
Add fine-grained tokens to GITHUB_TOKEN_PATTERNS
aac4202
@mbg
Use enum for token types
49cdf74
@mbg
Extend unit tests to cover all token types
0ae8b05
@mbg
Add isAuthToken function, with tests
0fcbec3
@mbg
Move makeTestToken to testing-utils
c12cf8d
@mbg
Warn if a private registry configuration uses a PAT, but has no username
9fccf27
@mbg mbg self-assigned this Jan 24, 2026
@mbg
mbg requested a review from a team as a code owner January 24, 2026 13:07
Copilot AI review requested due to automatic review settings January 24, 2026 13:07
@github-actions github-actions Bot added the size/M Should be of average difficulty to review label Jan 24, 2026
Copilot started reviewing on behalf of mbg January 24, 2026 13:07
View session
github-advanced-security[bot]
github-advanced-security AI found potential problems Jan 24, 2026
View reviewed changes
Comment thread src/start-proxy.test.ts Dismissed

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Jan 24, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 PR adds detection of PAT misuse in private registry credentials and enhances the artifact scanner to recognize fine-grained GitHub tokens, with corresponding test coverage and support utilities.

Changes:

  • Extend the artifact scanner with a TokenType enum, reusable token patterns (including fine-grained PATs), and an exported isAuthToken helper used both in scanning and elsewhere.
  • Update getCredentials in start-proxy.ts to warn when a GitHub PAT (classic or fine-grained) is used without a username, and add tests to verify logging behavior.
  • Introduce makeTestToken and expand artifact-scanner tests to systematically validate token detection and logging for all supported token types.

Reviewed changes

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

Show a summary per file
File Description
src/testing-utils.ts Adds makeTestToken helper for generating deterministic token-like strings used in new tests.
src/start-proxy.ts Imports the artifact scanner, introduces isPAT, and logs a warning when credentials use a PAT without a username.
src/start-proxy.test.ts Adds a test that verifies getCredentials still accepts PAT-based credentials but logs the expected warning when no username is provided.
src/artifact-scanner.ts Refactors token pattern handling into typed TokenType/TokenPattern, adds explicit PAT patterns (classic & fine-grained), exposes isAuthToken, and adapts scanning to use the typed patterns.
src/artifact-scanner.test.ts Reworks tests to cover makeTestToken, isAuthToken, and all token types in scanArtifactsForTokens, checking both thrown error messages and logged summaries.
lib/* (multiple files) Generated JavaScript outputs corresponding to the updated TypeScript sources; not manually reviewed per repository guidelines.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/artifact-scanner.ts
Comment on lines +86 to +95
export function isAuthToken(
value: string,
patterns: TokenPattern[] = GITHUB_TOKEN_PATTERNS,
) {
for (const { type, pattern } of patterns) {
if (pattern.test(value)) {
return type;
}
}
return undefined;

Copilot AI Jan 24, 2026

Copy link

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.

isAuthToken iterates over TokenPattern values whose regexes all use the /g flag and calls pattern.test(value) directly. Because RegExp.prototype.test with a global regex mutates and uses lastIndex, repeated calls with the same value can alternate between true and false, so isAuthToken is not reliably idempotent and may fail to detect tokens on subsequent calls. Consider either resetting pattern.lastIndex before each test or using non-global regexes for this helper (while keeping the /g-flagged patterns for the scanning code that needs them).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot uses AI. Check for mistakes.
Comment thread lib/start-proxy-action.js
var core7 = __toESM(require_core());

// src/artifact-scanner.ts
var exec = __toESM(require_exec());

Copilot AI Jan 24, 2026

Copy link

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.

Unused variable exec.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot uses AI. Check for mistakes.
henrymercer
henrymercer reviewed Jan 26, 2026
View reviewed changes
Comment thread src/artifact-scanner.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/start-proxy.ts
(isDefined(e.token) && isPAT(e.token)))
) {
logger.warning(
`A ${e.type} private registry is configured for ${e.host || e.url} using a GitHub Personal Access Token (PAT), but no username was provided. ` +

@henrymercer henrymercer Jan 26, 2026

Copy link
Copy Markdown
Contributor

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.

Can we be sure that the URL will not contain any credentials?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbg mbg Jan 26, 2026

Copy link
Copy Markdown
Member Author

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.

Only the password/token fields are encrypted in the backend, so users shouldn't be storing any credentials in the host/url fields. (I believe the UI says something to that effect as well when configuring a registry.)

In any case, we have always been logging the host/url values in credentialToStr, which is always called by:

    logger.info(
      `Credentials loaded for the following registries:\n ${credentials
        .map((c) => credentialToStr(c))
        .join("\n")}`,
    );

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mbg
Merge branch 'main' into mbg/start-proxy/warn-if-pat-without-username
0a0c3a2
@mbg
mbg requested a review from henrymercer January 27, 2026 11:31
@mbg
Use .match in isAuthToken and add repeated call to test
c656a11
@mbg
mbg force-pushed the mbg/start-proxy/warn-if-pat-without-username branch from ccb9f57 to c656a11 Compare January 27, 2026 11:45
henrymercer
henrymercer approved these changes Jan 27, 2026
View reviewed changes
@mbg
mbg merged commit 34cae51 into main Jan 27, 2026
250 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mbg
mbg deleted the mbg/start-proxy/warn-if-pat-without-username branch January 27, 2026 14:07
@mbg mbg mentioned this pull request Jan 27, 2026
Update JS for ES2022 #3436
Merged
This was referenced Feb 2, 2026
Merge main into releases/v4 #3447
Merged
Merge releases/v4 into releases/v3 #3449
Merged
@rennerdo30 rennerdo30 mentioned this pull request Oct 21, 2026
[Historical PR] chore(deps): bump github/codeql-action from 3 to 4 rennerdo30/watch-together#5
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@henrymercer henrymercer henrymercer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@mbg mbg

Labels

size/M Should be of average difficulty to review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@mbg @henrymercer @github-advanced-security
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.