mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-29 19:34:29 +01:00
The secrets check no longer reports an 11-digit GitHub Actions run id as a phone number when code names it `runId`, `RunGithubID` or passes it to a run call such as `resolveRunDetection(...)`. Why: Go and TypeScript test fixtures tripped a phone-number finding, and `gstack-post` asked for confirmation on PR bodies that quoted them. Nothing to do; every number the check reported before still reports. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team Review-Finding: p2/outside-voice#1 reader=outside-voice Review-Finding: p2/outside-voice#2 reader=outside-voice Review-Finding: p2/red-team#1 reader=red-team Review-Finding: p2/adversarial-native#1 reader=adversarial-native Review-Finding: p2/adversarial-native#3 reader=adversarial-native
This commit is contained in:
1 parent
4b8c7005dc
commit
be9b34e3dc
4 files changed
+112
-1
No files matched your search
@@ -0,0 +1 @@
|
||||
**The secrets check no longer reports an 11-digit GitHub Actions run id as a phone number when code names it with a camelCase run identifier** such as `runId: <id>`, `RunGithubID: <id>` or `resolveRunDetection(t, db, d, <id>, ...)` (#4861). Everything the check reported before still reports, including a plain `"run": <n>` in JSON, a phone-named key such as `phoneRun` or `contactRunId`, an id with more text after it in the same value, and any number that isn't exactly 11 digits.
|
||||
@@ -3203,6 +3203,16 @@ exact tokens it finds in these positions:
|
||||
check accept it too, not only `gstack-post`. A national number written
|
||||
without its `+` right after a run word reads as a run id there; that is the
|
||||
accepted residual of the ruling that a run id is not a phone number;
|
||||
- an 11-digit id that is the whole value of a key or assignment named by a
|
||||
camelCase run identifier (`runId: <id>`, `RunGithubID: <id>`,
|
||||
`workflowRunID = <id>`, `lastRun := <id>`), or an argument of a call whose
|
||||
name ends in `Run` plus `Id`, `Detection`, `Status`, `Result`, `Attempt`,
|
||||
`Log`, `Job` or `Artifact` after only plain identifier arguments
|
||||
(`resolveRunDetection(t, db, d, <id>, ...)`). The scanner itself exempts it
|
||||
(`isCiRunIdentifier`). A plain `"run": <n>` key, `runner` or `brunId`, an
|
||||
id with more text after it in the same value, and any line with a phone word
|
||||
(`phone`, `tel`, `mobile`, `cell`, `contact`, `call`, …) within 80
|
||||
characters of the id still report (#4861);
|
||||
- every 11-digit id chained after an allowlisted one through `, `, ` and `,
|
||||
` & `, ` or ` or ` / `, optionally with a `(#1234)` between
|
||||
(`screen 40269992077 (#3434) and 40275443393 (#3453)`);
|
||||
|
||||
+37
-1
@@ -453,20 +453,56 @@ export function isNumericMetadataValue(span: string, match: RegExpExecArray): bo
|
||||
* owner's ruling that a run id is not a phone number; gstack-post's chained-id
|
||||
* allowlist reads the same position the same way. The same digits anywhere
|
||||
* else still report.
|
||||
*
|
||||
* Code names the run with a camelCase identifier instead (#4861), so an
|
||||
* 11-digit id also counts as the whole value of a key or assignment named by
|
||||
* a compound run identifier: Run after a lowercase letter or digit, optionally
|
||||
* followed by Id/ID or GithubId/GitHubID/ActionsId/WorkflowId (`lastRun := <id>`,
|
||||
* `RunGithubID: <id>` inside a struct, `workflowRunID = <id>`), or run/Run
|
||||
* starting the name with one of those Id endings (`runId: <id>`); or as an
|
||||
* argument of a call whose name ends in Run plus Id, Detection, Status,
|
||||
* Result, Attempt, Log, Job or Artifact, after only plain identifier
|
||||
* arguments (`resolveRunDetection(t, db, d, <id>,`). A plain `run` key is
|
||||
* left to the run-word rule above, so a quoted JSON `"run": <n>` still
|
||||
* reports. The id must end the value (a closing quote matching an opening
|
||||
* one, else the line end, a space, `,`, `;`, `)`, `}` or `]`), so
|
||||
* `runId: '<n>-<stamp>'` reports. `runner`, `brunId` and `myRunnerPhone`
|
||||
* exempt nothing, and neither does a phone word anywhere on the line within
|
||||
* 80 characters either side of the id, read as a substring of the lowercased
|
||||
* text (phone, tel, mobile, cell, fax, sms, contact, msisdn, whatsapp, call,
|
||||
* dial: `phoneRun`, `cellphoneRunId`, `user.phone.lastRun`,
|
||||
* `"phone-lastRunId"`, `resolveRunDetection(t, phone, <n>`,
|
||||
* `lastRun = <n>; // mobile`), nor a key or call whose name the
|
||||
* 80-character window cuts off, since the cut part could hold one.
|
||||
*/
|
||||
const CI_ID_POSITION_BEFORE =
|
||||
/(?:--(?:run|job)(?:-id)?(?:[ \t]+|[ \t]*=[ \t]*)|\bgh[ \t]+run[ \t]+(?:view|watch|rerun|download|cancel)[ \t]+|(?:^|[\s\/(\[<"'])actions\/runs\/|\/jobs?\/|(?:run|job)_id["']?[ \t]*[:=][ \t]*["']?)$/i;
|
||||
const CI_RUN_LIST = /(?<![\w-])runs?=\d{11,12}\/\d{1,3}(?:,\d{11,12}\/\d{1,3})*(?![\w\/])/gi;
|
||||
/** A run word with an optional ':' '#' '=' right before an 11-digit token; shared with gstack-post's chained-id allowlist. */
|
||||
export const CI_RUN_WORD_BEFORE = /\b(?:runs?|screens?|gates?|backstop|bisect|rerun|dispatch(?:ed)?|failed|passed)\s*[:#=]?\s*$/i;
|
||||
const RUN_KEY_BEFORE = /(?<![\w$])([A-Za-z_$][\w$]*)["']?[ \t]*(?::=|[:=])[ \t]*(["']?)$/;
|
||||
const RUN_CALL_BEFORE = /(?<![\w$])([A-Za-z_$][\w$]*)\((?:[ \t]*[A-Za-z_$][\w$.]*[ \t]*,)*[ \t]*$/;
|
||||
const RUN_KEY_NAME = /(?:[a-z\d]Run(?:(?:Git[Hh]ub|Actions?|Workflow)?I[Dd])?|^[rR]un(?:Git[Hh]ub|Actions?|Workflow)?I[Dd])$/;
|
||||
const RUN_CALL_NAME = /(?:^[rR]|[a-z\d]R)un(?:I[Dd]s?|Detection|Status|Results?|Attempts?|Logs?|Jobs?|Artifacts?)$/;
|
||||
const PHONE_WORD = /phone|tel|mobile|cell|fax|sms|contact|msisdn|whatsapp|call|dial/;
|
||||
function isCamelCaseRunIdPosition(before: string, after: string, truncated: boolean): boolean {
|
||||
const key = RUN_KEY_BEFORE.exec(before);
|
||||
const call = RUN_CALL_BEFORE.exec(before);
|
||||
const hit = key && RUN_KEY_NAME.test(key[1]!) ? key : call && RUN_CALL_NAME.test(call[1]!) ? call : null;
|
||||
if (!hit || (truncated && hit.index === 0)) return false;
|
||||
const quote = hit === key ? key[2]! : "";
|
||||
if (quote ? after[0] !== quote : !/^(?:$|[\s,;)}\]])/.test(after)) return false;
|
||||
return !PHONE_WORD.test((before + after).toLowerCase());
|
||||
}
|
||||
export function isCiRunIdentifier(span: string, match: RegExpExecArray): boolean {
|
||||
if (!/^\d+$/.test(span)) return false;
|
||||
const input = match.input ?? "";
|
||||
const { start } = spanBounds(match);
|
||||
const lineStart = input.lastIndexOf("\n", start - 1) + 1;
|
||||
const before = input.slice(Math.max(lineStart, start - 80), start);
|
||||
if (CI_ID_POSITION_BEFORE.test(before) || (span.length === 11 && CI_RUN_WORD_BEFORE.test(before))) return true;
|
||||
const lineEnd = input.indexOf("\n", start);
|
||||
const after = input.slice(start + span.length, Math.min(lineEnd < 0 ? input.length : lineEnd, start + span.length + 80));
|
||||
if (CI_ID_POSITION_BEFORE.test(before) || (span.length === 11 && (CI_RUN_WORD_BEFORE.test(before) || isCamelCaseRunIdPosition(before, after, start - 80 > lineStart)))) return true;
|
||||
const line = input.slice(lineStart, lineEnd < 0 ? input.length : lineEnd);
|
||||
const at = start - lineStart;
|
||||
return [...line.matchAll(CI_RUN_LIST)].some(m => m.index! < at && at + span.length <= m.index! + m[0].length);
|
||||
|
||||
@@ -462,6 +462,70 @@ describe("pii.phone.e164: GitHub Actions run and job ids in their id positions",
|
||||
);
|
||||
});
|
||||
|
||||
// #4861: Go and TypeScript fixtures name the run id with a camelCase identifier, not a plain run word.
|
||||
describe("pii.phone.e164: an 11-digit run id after a camelCase run identifier (#4861)", () => {
|
||||
table(
|
||||
"pii.phone.e164",
|
||||
"MEDIUM",
|
||||
[
|
||||
"\tRunGithubID: 12345678901,",
|
||||
" runId: 12345678901,",
|
||||
"\tresolveRunDetection(t, db, d, 12345678901, createdAt)",
|
||||
'{"runId":38969924945,"pr":3225}',
|
||||
"const workflowRunID = 40477638211;",
|
||||
"lastRun := 40477638211",
|
||||
"RunGitHubId: 40477638211",
|
||||
"s.getRunStatus(ctx, 40477638211)",
|
||||
],
|
||||
[
|
||||
// A phone-shaped value under a phone-named key, or a Run that is not a whole camelCase word, still reports.
|
||||
"userPhone: 14155551234",
|
||||
"phoneNumber: 14155551234",
|
||||
"myRunnerPhone: 14155551234",
|
||||
"callRunPhone: 14155551234",
|
||||
"runPhone: 14155551234",
|
||||
"RunTel: 14155551234",
|
||||
"runMobile = 14155551234",
|
||||
"runContact: 14155551234",
|
||||
"phoneRun: 14155551234",
|
||||
"contactRunId: 14155551234",
|
||||
"cellphoneRunId: 14155551234",
|
||||
"homephoneRun = 14155551234",
|
||||
"msisdnRunId: 14155551234",
|
||||
// A phone word in a quoted, hyphenated or dotted key, a receiver, an outer call or a trailing comment still reports.
|
||||
"mobile-lastRun: 14155551234",
|
||||
'{"phone-lastRunId": 14155551234}',
|
||||
"user.phone.lastRun = 14155551234",
|
||||
"customer.contact.workflowRunId = 14155551234",
|
||||
"phone.getRunLogs(14155551234)",
|
||||
"phoneApi.getRunLogs(ctx, 14155551234)",
|
||||
"dialPhone(getRunStatus(c, 14155551234))",
|
||||
"const lastRun = 14155551234; // mom's mobile",
|
||||
"runner: 14155551234",
|
||||
"rerunnerId: 14155551234",
|
||||
"brunId: 14155551234",
|
||||
// A call that only mentions a run, or passes a phone-named argument, still reports.
|
||||
"callRun(14155551234)",
|
||||
"sendRunNotification(user, 14155551234)",
|
||||
"resolveRunDetection(t, phone, 14155551234)",
|
||||
"resolveRunDetection(t, db, \"x\", 14155551234)",
|
||||
// A call name the 80-character window cuts off could hide a phone word in the cut part.
|
||||
"phoneRunStatus(alphaBetaGammaDeltaArg1, alphaBetaGammaDeltaArg2, alphaBetaGamma3, 14155551234)",
|
||||
// Separated from the identifier, not 11 digits, or written with a + or separators.
|
||||
"runId: 1, phone: 14155551234",
|
||||
"runId 14155551234",
|
||||
"runId: 4155550123",
|
||||
"runId: +14155551234",
|
||||
"runId: 1-415-555-1234",
|
||||
// A plain run key in quoted JSON stays with the run-word rule, and the id must be the whole value.
|
||||
'{"run": 14155551234}',
|
||||
"runId: '14155551234-20261109173601'",
|
||||
'"sourceRun": "14155551234 slice 4"',
|
||||
"lastRun = 14155551234/2",
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
describe("pii.phone.e164: run ids in a runs= list or an actions/runs/ path (GST-1227)", () => {
|
||||
table(
|
||||
"pii.phone.e164",
|
||||
|
||||
Reference in new issue
Block a user