| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
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:
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.
| export function isAuthToken( | ||
| value: string, | ||
| patterns: TokenPattern[] = GITHUB_TOKEN_PATTERNS, | ||
| ) { | ||
| for (const { type, pattern } of patterns) { | ||
| if (pattern.test(value)) { | ||
| return type; | ||
| } | ||
| } | ||
| return undefined; |
There was a problem hiding this comment.
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.
| var core7 = __toESM(require_core()); | ||
|
|
||
| // src/artifact-scanner.ts | ||
| var exec = __toESM(require_exec()); |
There was a problem hiding this comment.
Unused variable exec.
Sorry, something went wrong.
| (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. ` + |
There was a problem hiding this comment.
Can we be sure that the URL will not contain any credentials?
Sorry, something went wrong.
There was a problem hiding this comment.
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.
| Back | FazBrowse Home | New Git URL |
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:
Which use cases does this change impact?
Workflow types:
Products:
Environments:
How did/will you validate this change?
If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist