@cleartrip/frontguard 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +50 -31
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/templates/bitbucket-pipelines.yml +10 -0
package/dist/cli.js
CHANGED
|
@@ -2547,19 +2547,6 @@ function formatBitbucketPrSnippet(report) {
|
|
|
2547
2547
|
const downloadsName = process.env.FRONTGUARD_REPORT_DOWNLOAD_NAME?.trim();
|
|
2548
2548
|
const downloadsPage = bitbucketDownloadsPageUrl();
|
|
2549
2549
|
const pipeline = bitbucketPipelineResultsUrl();
|
|
2550
|
-
let linkLine;
|
|
2551
|
-
if (publicReport) {
|
|
2552
|
-
linkLine = `**[Open full FrontGuard report (HTML)](${publicReport})** \u2014 interactive report in the browser (all findings).`;
|
|
2553
|
-
} else if (downloadsName && downloadsPage) {
|
|
2554
|
-
linkLine = `**[Repo Downloads](${downloadsPage})** \u2014 open \`${downloadsName}\` (uploaded by this pipeline). Download the file, then open it in a browser.`;
|
|
2555
|
-
} else if (pipeline) {
|
|
2556
|
-
linkLine = [
|
|
2557
|
-
`**[Open this pipeline run](${pipeline})** (Bitbucket login required).`,
|
|
2558
|
-
"On that page: open the **Artifacts** section \u2192 download **`frontguard-report.html`** \u2192 open the file in your browser to see the full interactive report."
|
|
2559
|
-
].join(" ");
|
|
2560
|
-
} else {
|
|
2561
|
-
linkLine = "_Run FrontGuard inside Bitbucket Pipelines so `BITBUCKET_REPO_FULL_NAME` and `BITBUCKET_BUILD_NUMBER` are set, or set `FRONTGUARD_PUBLIC_REPORT_URL` after uploading the HTML._";
|
|
2562
|
-
}
|
|
2563
2550
|
const { riskScore, results } = report;
|
|
2564
2551
|
const blocks = results.reduce(
|
|
2565
2552
|
(n3, r4) => n3 + r4.findings.filter((f4) => f4.severity === "block").length,
|
|
@@ -2569,25 +2556,48 @@ function formatBitbucketPrSnippet(report) {
|
|
|
2569
2556
|
(n3, r4) => n3 + r4.findings.filter((f4) => f4.severity === "warn").length,
|
|
2570
2557
|
0
|
|
2571
2558
|
);
|
|
2572
|
-
const
|
|
2573
|
-
"
|
|
2559
|
+
const out = [
|
|
2560
|
+
"FrontGuard report (short summary)",
|
|
2574
2561
|
"",
|
|
2575
|
-
|
|
2576
|
-
""
|
|
2577
|
-
linkLine,
|
|
2578
|
-
"",
|
|
2579
|
-
"| Check | Status |",
|
|
2580
|
-
"|:--|:--|"
|
|
2562
|
+
`Risk: ${riskScore} | Blocking: ${blocks} | Warnings: ${warns}`,
|
|
2563
|
+
""
|
|
2581
2564
|
];
|
|
2565
|
+
if (publicReport) {
|
|
2566
|
+
out.push("Full interactive report (open in browser):");
|
|
2567
|
+
out.push(publicReport);
|
|
2568
|
+
out.push("");
|
|
2569
|
+
} else if (downloadsName && downloadsPage) {
|
|
2570
|
+
out.push("HTML report is in Repository \u2192 Downloads. Open this page while logged in:");
|
|
2571
|
+
out.push(downloadsPage);
|
|
2572
|
+
out.push(`File name: ${downloadsName}`);
|
|
2573
|
+
out.push("Download the file, then open it in a browser.");
|
|
2574
|
+
out.push("");
|
|
2575
|
+
} else if (pipeline) {
|
|
2576
|
+
out.push(
|
|
2577
|
+
"There is no direct \u201CHTML URL\u201D for pipeline artifacts in Bitbucket. Use this pipeline run (log in), then Artifacts \u2192 frontguard-report.html:"
|
|
2578
|
+
);
|
|
2579
|
+
out.push(pipeline);
|
|
2580
|
+
out.push("");
|
|
2581
|
+
out.push(
|
|
2582
|
+
"Steps: open the link \u2192 scroll to Artifacts \u2192 download frontguard-report.html \u2192 open the file on your machine."
|
|
2583
|
+
);
|
|
2584
|
+
out.push("");
|
|
2585
|
+
} else {
|
|
2586
|
+
out.push(
|
|
2587
|
+
"Add a link: run FrontGuard inside Bitbucket Pipelines, or set FRONTGUARD_PUBLIC_REPORT_URL after uploading the HTML somewhere HTTPS."
|
|
2588
|
+
);
|
|
2589
|
+
out.push("");
|
|
2590
|
+
}
|
|
2591
|
+
out.push("Checks:");
|
|
2582
2592
|
for (const r4 of results) {
|
|
2583
|
-
const status = r4.skipped ? `
|
|
2584
|
-
|
|
2593
|
+
const status = r4.skipped ? `skipped (${r4.skipped.slice(0, 100)}${r4.skipped.length > 100 ? "\u2026" : ""})` : r4.findings.length === 0 ? "clean" : `${r4.findings.length} finding(s)`;
|
|
2594
|
+
out.push(`- ${r4.checkId}: ${status}`);
|
|
2585
2595
|
}
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2596
|
+
out.push("");
|
|
2597
|
+
out.push(
|
|
2598
|
+
"Do not paste the long frontguard-report.md into PR comments. Full text output is in that file / pipeline artifacts only."
|
|
2589
2599
|
);
|
|
2590
|
-
return
|
|
2600
|
+
return out.join("\n");
|
|
2591
2601
|
}
|
|
2592
2602
|
|
|
2593
2603
|
// src/ci/parse-ai-disclosure.ts
|
|
@@ -2687,10 +2697,10 @@ async function resolvePrNumber() {
|
|
|
2687
2697
|
const raw = process.env.FRONTGUARD_PR_NUMBER ?? process.env.PR_NUMBER;
|
|
2688
2698
|
const n3 = Number(raw);
|
|
2689
2699
|
if (Number.isFinite(n3) && n3 > 0) return n3;
|
|
2690
|
-
const
|
|
2691
|
-
if (!
|
|
2700
|
+
const path17 = process.env.GITHUB_EVENT_PATH;
|
|
2701
|
+
if (!path17) return null;
|
|
2692
2702
|
try {
|
|
2693
|
-
const payload = JSON.parse(await fs.readFile(
|
|
2703
|
+
const payload = JSON.parse(await fs.readFile(path17, "utf8"));
|
|
2694
2704
|
const num = payload.pull_request?.number;
|
|
2695
2705
|
return typeof num === "number" && num > 0 ? num : null;
|
|
2696
2706
|
} catch {
|
|
@@ -5991,7 +6001,16 @@ async function runFrontGuard(opts) {
|
|
|
5991
6001
|
}
|
|
5992
6002
|
if (opts.prCommentOut) {
|
|
5993
6003
|
const snippet = formatBitbucketPrSnippet(report);
|
|
5994
|
-
|
|
6004
|
+
const abs = path4.isAbsolute(opts.prCommentOut) ? opts.prCommentOut : path4.join(opts.cwd, opts.prCommentOut);
|
|
6005
|
+
await fs.writeFile(abs, snippet, "utf8");
|
|
6006
|
+
g.stderr.write(
|
|
6007
|
+
`
|
|
6008
|
+
FrontGuard: wrote Bitbucket PR comment text to ${abs} (${snippet.length} bytes).
|
|
6009
|
+
Use ONLY this file in your POST \u2026/pullrequests/{id}/comments payload (content.raw).
|
|
6010
|
+
Do not post frontguard-report.md or captured stdout \u2014 that is the long markdown log.
|
|
6011
|
+
|
|
6012
|
+
`
|
|
6013
|
+
);
|
|
5995
6014
|
}
|
|
5996
6015
|
if (opts.markdown) {
|
|
5997
6016
|
g.stdout.write(report.markdown + "\n");
|