shield-llm 0.5.1 → 0.5.3
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/{chunk-IB7T5OJ2.js → chunk-CWJWN44I.js} +53 -43
- package/dist/cli.js +230 -58
- package/dist/index.js +1 -2
- package/package.json +1 -13
- package/dist/chunk-AH5UVQFM.js +0 -544
- package/dist/chunk-I7M3BZK7.js +0 -20
- package/dist/token-4MGV4LR3.js +0 -70
- package/dist/token-util-U5SGZSEU.js +0 -6
|
@@ -5106,8 +5106,8 @@ function isIpPrivate(ip) {
|
|
|
5106
5106
|
const mapped = addr.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
|
|
5107
5107
|
if (mapped) addr = mapped[1];
|
|
5108
5108
|
if (isIP(addr) === 4) {
|
|
5109
|
-
const [a, b,
|
|
5110
|
-
if ([a, b,
|
|
5109
|
+
const [a, b, c2, d] = addr.split(".").map(Number);
|
|
5110
|
+
if ([a, b, c2, d].some((p) => Number.isNaN(p) || p < 0 || p > 255)) {
|
|
5111
5111
|
return true;
|
|
5112
5112
|
}
|
|
5113
5113
|
if (a === 0) return true;
|
|
@@ -5117,7 +5117,7 @@ function isIpPrivate(ip) {
|
|
|
5117
5117
|
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
5118
5118
|
if (a === 192 && b === 168) return true;
|
|
5119
5119
|
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
5120
|
-
if (a === 255 && b === 255 &&
|
|
5120
|
+
if (a === 255 && b === 255 && c2 === 255 && d === 255) return true;
|
|
5121
5121
|
return false;
|
|
5122
5122
|
}
|
|
5123
5123
|
const lower = addr.toLowerCase();
|
|
@@ -6669,39 +6669,50 @@ function evaluateThresholds(report, thresholds) {
|
|
|
6669
6669
|
};
|
|
6670
6670
|
}
|
|
6671
6671
|
|
|
6672
|
+
// src/display/colors.ts
|
|
6673
|
+
import { styleText } from "util";
|
|
6674
|
+
var make = (fmt) => (text) => styleText(fmt, text);
|
|
6675
|
+
var c = {
|
|
6676
|
+
cyan: make("cyan"),
|
|
6677
|
+
red: make("red"),
|
|
6678
|
+
green: make("green"),
|
|
6679
|
+
yellow: make("yellow"),
|
|
6680
|
+
blue: make("blue"),
|
|
6681
|
+
gray: make("gray"),
|
|
6682
|
+
white: make("white"),
|
|
6683
|
+
bold: make("bold"),
|
|
6684
|
+
dim: make("dim"),
|
|
6685
|
+
redBold: make(["red", "bold"]),
|
|
6686
|
+
greenBold: make(["green", "bold"]),
|
|
6687
|
+
bgYellowBlackBold: make(["bgYellow", "black", "bold"])
|
|
6688
|
+
};
|
|
6689
|
+
|
|
6672
6690
|
// src/reporters/compliance.ts
|
|
6673
|
-
import chalk from "chalk";
|
|
6674
6691
|
function formatComplianceTerminal(result, target) {
|
|
6675
6692
|
const lines = [];
|
|
6676
6693
|
lines.push("");
|
|
6677
|
-
lines.push(
|
|
6694
|
+
lines.push(c.bold("\u2550\u2550\u2550 EU AI Act Compliance \u2550\u2550\u2550"));
|
|
6678
6695
|
lines.push("");
|
|
6679
|
-
lines.push(` Target: ${
|
|
6696
|
+
lines.push(` Target: ${c.white(target)}`);
|
|
6680
6697
|
lines.push(` Score: ${complianceScoreColor(result.overallScore)}`);
|
|
6681
6698
|
lines.push(
|
|
6682
6699
|
` Status: ${statusColor(result.status, getComplianceLabel(result.status))}`
|
|
6683
6700
|
);
|
|
6684
6701
|
lines.push(` Framework: ${result.framework} (${result.frameworkVersion})`);
|
|
6685
6702
|
lines.push("");
|
|
6686
|
-
lines.push(
|
|
6703
|
+
lines.push(c.bold(" Article Coverage:"));
|
|
6687
6704
|
const sorted = [...result.aspects].filter((a) => a.totalTests > 0).sort((a, b) => a.score - b.score);
|
|
6688
6705
|
for (const aspect of sorted) {
|
|
6689
6706
|
const label = ASPECT_ARTICLE_LABELS[aspect.aspect];
|
|
6690
6707
|
const bar = makeBar(aspect.score, 20);
|
|
6691
6708
|
const scoreStr = complianceScoreColor(aspect.score);
|
|
6692
|
-
const stats =
|
|
6693
|
-
|
|
6694
|
-
);
|
|
6695
|
-
lines.push(
|
|
6696
|
-
` ${label.padEnd(16)} ${bar} ${scoreStr} ${stats}`
|
|
6697
|
-
);
|
|
6709
|
+
const stats = c.dim(`${aspect.passedTests}/${aspect.totalTests} passed`);
|
|
6710
|
+
lines.push(` ${label.padEnd(16)} ${bar} ${scoreStr} ${stats}`);
|
|
6698
6711
|
}
|
|
6699
6712
|
if (result.nonCompliances.length > 0) {
|
|
6700
6713
|
lines.push("");
|
|
6701
6714
|
lines.push(
|
|
6702
|
-
|
|
6703
|
-
` Non-Compliances (${result.nonCompliances.length}):`
|
|
6704
|
-
)
|
|
6715
|
+
c.redBold(` Non-Compliances (${result.nonCompliances.length}):`)
|
|
6705
6716
|
);
|
|
6706
6717
|
const seen = /* @__PURE__ */ new Set();
|
|
6707
6718
|
for (const nc of result.nonCompliances) {
|
|
@@ -6709,7 +6720,7 @@ function formatComplianceTerminal(result, target) {
|
|
|
6709
6720
|
if (seen.has(key)) continue;
|
|
6710
6721
|
seen.add(key);
|
|
6711
6722
|
lines.push(
|
|
6712
|
-
` ${
|
|
6723
|
+
` ${c.red("\u2717")} ${nc.testName} \u2014 ${nc.article.articleNumber} (${nc.article.complianceAspect})`
|
|
6713
6724
|
);
|
|
6714
6725
|
}
|
|
6715
6726
|
}
|
|
@@ -6719,19 +6730,17 @@ function formatComplianceTerminal(result, target) {
|
|
|
6719
6730
|
if (compliantAspects.length > 0) {
|
|
6720
6731
|
lines.push("");
|
|
6721
6732
|
lines.push(
|
|
6722
|
-
|
|
6723
|
-
` Compliant (${compliantAspects.length}/7 aspects):`
|
|
6724
|
-
)
|
|
6733
|
+
c.greenBold(` Compliant (${compliantAspects.length}/7 aspects):`)
|
|
6725
6734
|
);
|
|
6726
6735
|
for (const a of compliantAspects) {
|
|
6727
6736
|
lines.push(
|
|
6728
|
-
` ${
|
|
6737
|
+
` ${c.green("\u2713")} ${ASPECT_ARTICLE_LABELS[a.aspect]} \u2014 ${a.aspect} (${a.score}%)`
|
|
6729
6738
|
);
|
|
6730
6739
|
}
|
|
6731
6740
|
}
|
|
6732
6741
|
lines.push("");
|
|
6733
|
-
lines.push(
|
|
6734
|
-
lines.push(
|
|
6742
|
+
lines.push(c.dim(" Disclaimer: This is an automated assessment, not a"));
|
|
6743
|
+
lines.push(c.dim(" legal compliance certification."));
|
|
6735
6744
|
lines.push("");
|
|
6736
6745
|
return lines.join("\n");
|
|
6737
6746
|
}
|
|
@@ -6769,27 +6778,27 @@ function makeBar(score, width) {
|
|
|
6769
6778
|
const filledChar = "\u2588";
|
|
6770
6779
|
const emptyChar = "\u2591";
|
|
6771
6780
|
const bar = filledChar.repeat(filled) + emptyChar.repeat(empty);
|
|
6772
|
-
if (score >= 90) return
|
|
6773
|
-
if (score >= 70) return
|
|
6774
|
-
if (score >= 40) return
|
|
6775
|
-
return
|
|
6781
|
+
if (score >= 90) return c.green(bar);
|
|
6782
|
+
if (score >= 70) return c.yellow(bar);
|
|
6783
|
+
if (score >= 40) return c.red(bar);
|
|
6784
|
+
return c.redBold(bar);
|
|
6776
6785
|
}
|
|
6777
6786
|
function complianceScoreColor(score) {
|
|
6778
|
-
if (score >= 90) return
|
|
6779
|
-
if (score >= 70) return
|
|
6780
|
-
if (score >= 40) return
|
|
6781
|
-
return
|
|
6787
|
+
if (score >= 90) return c.greenBold(`${score}%`);
|
|
6788
|
+
if (score >= 70) return c.yellow(`${score}%`);
|
|
6789
|
+
if (score >= 40) return c.red(`${score}%`);
|
|
6790
|
+
return c.redBold(`${score}%`);
|
|
6782
6791
|
}
|
|
6783
6792
|
function statusColor(status, label) {
|
|
6784
6793
|
switch (status) {
|
|
6785
6794
|
case "COMPLIANT":
|
|
6786
|
-
return
|
|
6795
|
+
return c.greenBold(label);
|
|
6787
6796
|
case "PARTIALLY_COMPLIANT":
|
|
6788
|
-
return
|
|
6797
|
+
return c.yellow(label);
|
|
6789
6798
|
case "NON_COMPLIANT":
|
|
6790
|
-
return
|
|
6799
|
+
return c.red(label);
|
|
6791
6800
|
case "CRITICAL":
|
|
6792
|
-
return
|
|
6801
|
+
return c.redBold(label);
|
|
6793
6802
|
default:
|
|
6794
6803
|
return label;
|
|
6795
6804
|
}
|
|
@@ -8810,22 +8819,22 @@ ${d.passedTests.map(passedTestRow).join("")} </tbody>
|
|
|
8810
8819
|
${pageFooter(d.generatedAt)}</div>
|
|
8811
8820
|
`;
|
|
8812
8821
|
}
|
|
8813
|
-
var coverageRow = (
|
|
8822
|
+
var coverageRow = (c2) => ` <tr>
|
|
8814
8823
|
<td>
|
|
8815
8824
|
<div class="owasp-category-cell">
|
|
8816
|
-
<span class="owasp-category-id">${esc(
|
|
8817
|
-
<span class="owasp-category-name">${esc(
|
|
8825
|
+
<span class="owasp-category-id">${esc(c2.id)}</span>
|
|
8826
|
+
<span class="owasp-category-name">${esc(c2.name)}</span>
|
|
8818
8827
|
</div>
|
|
8819
8828
|
</td>
|
|
8820
|
-
<td>${esc(
|
|
8821
|
-
<td>${esc(
|
|
8822
|
-
<td${
|
|
8829
|
+
<td>${esc(c2.tests)}</td>
|
|
8830
|
+
<td>${esc(c2.passed)}</td>
|
|
8831
|
+
<td${c2.failed > 0 ? ' style="color: var(--critical-text); font-weight: 600;"' : ""}>${esc(c2.failed)}</td>
|
|
8823
8832
|
<td>
|
|
8824
8833
|
<div class="score-mini-bar">
|
|
8825
8834
|
<div class="score-mini-bar-track">
|
|
8826
|
-
<div class="score-mini-bar-fill ${
|
|
8835
|
+
<div class="score-mini-bar-fill ${c2.percentage === 100 ? "full" : c2.percentage > 0 ? "partial" : "none"}" style="width: ${esc(c2.percentage)}%"></div>
|
|
8827
8836
|
</div>
|
|
8828
|
-
<span class="score-mini-text" style="color: ${
|
|
8837
|
+
<span class="score-mini-text" style="color: ${c2.percentage === 100 ? "var(--pass-text)" : "var(--high-text)"};">${esc(c2.percentage)}%</span>
|
|
8829
8838
|
</div>
|
|
8830
8839
|
</td>
|
|
8831
8840
|
</tr>
|
|
@@ -9125,6 +9134,7 @@ export {
|
|
|
9125
9134
|
buildAuthFromFlags,
|
|
9126
9135
|
loadSystemPrompt,
|
|
9127
9136
|
ConfigError,
|
|
9137
|
+
c,
|
|
9128
9138
|
analyzeJudgeHealth,
|
|
9129
9139
|
evaluateThresholds,
|
|
9130
9140
|
formatComplianceTerminal,
|