@securitychecks/cli 0.1.1 → 0.2.0

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/lib.d.ts CHANGED
@@ -905,4 +905,26 @@ type InvariantLike = {
905
905
  declare function getStaffQuestion(invariantId: string): string | null;
906
906
  declare function generateTestSkeleton(invariant: InvariantLike | null | undefined, framework: TestFramework, context?: string): string;
907
907
 
908
- export { type AggregateCalibrationConfig, type AggregateCalibrationData, type AggregateCalibrationResult, type AttackPath, type AttackStep, type AuditOptions, BASELINE_SCHEMA_VERSION, type BaselineEntry, type BaselineFile, CLIError, type CategorizationResult, type CategorizedFinding, type CloudEvaluateOptions, type CloudEvaluateResult, type CompoundingEffect, type CorrelatedFinding, type CorrelationResult, type CorrelationStats, type CorrelationTelemetryConfig, type ErrorCode, ErrorCodes, ErrorMessages, ErrorRemediation, type EvaluationProgressCallback, type FrameworkBaseline, type InvariantLike, type InvariantStats, type PatternStats, SUPPORTED_SCHEMA_RANGE, type ScanTelemetry, type SchemaValidationResult, type SharedContext, type TelemetryConfig, type TestFramework, WAIVER_SCHEMA_VERSION, type WaiverEntry, type WaiverFile, addToBaseline, addWaiver, attachFindingId, attachFindingIds, audit, buildTelemetry, calculateRelativeSeverity, categorizeFindings, checkCloudHealth, clearAggregateCache, correlateFindings, evaluateCloud, extractIdentityPayload, fetchAggregateCalibration, formatAggregateCalibrationSummary, formatCorrelatedFinding, formatCorrelationStats, generateFindingId, generateTestSkeleton, getCIExitCode, getCISummary, getCloudInvariants, getCurrentSchemaVersion, getExpiringWaivers, getFrameworkBaseline, getSkippedPatterns, getStaffQuestion, getValidWaiver, getVerifiedCorrelations, hasCollisions, isAggregateCalibrationDisabled, isCLIError, isCloudEvalAvailable, isInBaseline, isTelemetryDisabled, loadBaseline, loadWaivers, pruneBaseline, pruneExpiredWaivers, reportCorrelationFeedback, reportCorrelations, reportTelemetry, resolveCollisions, saveBaseline, saveWaivers, shouldSkipPattern, validateSchemaVersion, wrapError };
908
+ type Grade = 'A' | 'B' | 'C' | 'F';
909
+ interface ReadinessScore {
910
+ score: number;
911
+ grade: Grade;
912
+ total: number;
913
+ passed: number;
914
+ failed: number;
915
+ hasP0: boolean;
916
+ }
917
+ declare function getScoreGrade(score: number): Grade;
918
+ declare function computeReadinessScore(summary: {
919
+ total: number;
920
+ passed: number;
921
+ failed: number;
922
+ byPriority: {
923
+ P0: number;
924
+ P1: number;
925
+ P2: number;
926
+ };
927
+ }): ReadinessScore;
928
+ declare function formatScoreForCli(rs: ReadinessScore): string;
929
+
930
+ export { type AggregateCalibrationConfig, type AggregateCalibrationData, type AggregateCalibrationResult, type AttackPath, type AttackStep, type AuditOptions, BASELINE_SCHEMA_VERSION, type BaselineEntry, type BaselineFile, CLIError, type CategorizationResult, type CategorizedFinding, type CloudEvaluateOptions, type CloudEvaluateResult, type CompoundingEffect, type CorrelatedFinding, type CorrelationResult, type CorrelationStats, type CorrelationTelemetryConfig, type ErrorCode, ErrorCodes, ErrorMessages, ErrorRemediation, type EvaluationProgressCallback, type FrameworkBaseline, type Grade, type InvariantLike, type InvariantStats, type PatternStats, type ReadinessScore, SUPPORTED_SCHEMA_RANGE, type ScanTelemetry, type SchemaValidationResult, type SharedContext, type TelemetryConfig, type TestFramework, WAIVER_SCHEMA_VERSION, type WaiverEntry, type WaiverFile, addToBaseline, addWaiver, attachFindingId, attachFindingIds, audit, buildTelemetry, calculateRelativeSeverity, categorizeFindings, checkCloudHealth, clearAggregateCache, computeReadinessScore, correlateFindings, evaluateCloud, extractIdentityPayload, fetchAggregateCalibration, formatAggregateCalibrationSummary, formatCorrelatedFinding, formatCorrelationStats, formatScoreForCli, generateFindingId, generateTestSkeleton, getCIExitCode, getCISummary, getCloudInvariants, getCurrentSchemaVersion, getExpiringWaivers, getFrameworkBaseline, getScoreGrade, getSkippedPatterns, getStaffQuestion, getValidWaiver, getVerifiedCorrelations, hasCollisions, isAggregateCalibrationDisabled, isCLIError, isCloudEvalAvailable, isInBaseline, isTelemetryDisabled, loadBaseline, loadWaivers, pruneBaseline, pruneExpiredWaivers, reportCorrelationFeedback, reportCorrelations, reportTelemetry, resolveCollisions, saveBaseline, saveWaivers, shouldSkipPattern, validateSchemaVersion, wrapError };
package/dist/lib.js CHANGED
@@ -5,6 +5,7 @@ import { homedir } from 'os';
5
5
  import { join, dirname } from 'path';
6
6
  import { gzipSync } from 'zlib';
7
7
  import { randomUUID, createHash } from 'crypto';
8
+ import pc from 'picocolors';
8
9
 
9
10
  // src/audit.ts
10
11
  var CONFIG_DIR = join(homedir(), ".securitychecks");
@@ -1069,7 +1070,7 @@ function createEmptyWaiverFile(version = "0.0.0") {
1069
1070
  entries: {}
1070
1071
  };
1071
1072
  }
1072
- var CLI_VERSION = "0.1.1";
1073
+ var CLI_VERSION = "0.2.0";
1073
1074
  var SCHECK_DIR = ".scheck";
1074
1075
  var BASELINE_FILE = "baseline.json";
1075
1076
  var WAIVER_FILE = "waivers.json";
@@ -1718,7 +1719,7 @@ function toObservation(correlation, framework) {
1718
1719
  signals: correlation.compoundingEffect.signals
1719
1720
  },
1720
1721
  meta: {
1721
- clientVersion: "0.1.1",
1722
+ clientVersion: "0.2.0",
1722
1723
  requestId: randomUUID(),
1723
1724
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
1724
1725
  }
@@ -1736,7 +1737,7 @@ async function reportCorrelations(result, config, framework) {
1736
1737
  correlations: observations,
1737
1738
  summary: result.stats,
1738
1739
  meta: {
1739
- clientVersion: "0.1.1",
1740
+ clientVersion: "0.2.0",
1740
1741
  framework
1741
1742
  }
1742
1743
  };
@@ -1748,7 +1749,7 @@ async function reportCorrelations(result, config, framework) {
1748
1749
  headers: {
1749
1750
  "Content-Type": "application/json",
1750
1751
  ...config.apiKey && { Authorization: `Bearer ${config.apiKey}` },
1751
- "X-Client-Version": "0.1.1"
1752
+ "X-Client-Version": "0.2.0"
1752
1753
  },
1753
1754
  body: JSON.stringify(payload),
1754
1755
  signal: controller.signal
@@ -1824,7 +1825,7 @@ function buildTelemetry(result, options) {
1824
1825
  } : void 0,
1825
1826
  meta: {
1826
1827
  duration: result.duration,
1827
- clientVersion: "0.1.1",
1828
+ clientVersion: "0.2.0",
1828
1829
  mode: options.mode ?? (ciProvider ? "ci" : "manual"),
1829
1830
  ciProvider
1830
1831
  },
@@ -2181,7 +2182,36 @@ function indent(text, spaces) {
2181
2182
  function escapeString(text) {
2182
2183
  return text.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
2183
2184
  }
2185
+ function getScoreGrade(score) {
2186
+ if (score >= 90) return "A";
2187
+ if (score >= 70) return "B";
2188
+ if (score >= 50) return "C";
2189
+ return "F";
2190
+ }
2191
+ function computeReadinessScore(summary) {
2192
+ const { total, passed, failed, byPriority } = summary;
2193
+ const hasP0 = byPriority.P0 > 0;
2194
+ if (total === 0) {
2195
+ return { score: 100, grade: "A", total: 0, passed: 0, failed: 0, hasP0: false };
2196
+ }
2197
+ let score = Math.round(100 * passed / total);
2198
+ if (hasP0 && score > 49) {
2199
+ score = 49;
2200
+ }
2201
+ return {
2202
+ score,
2203
+ grade: getScoreGrade(score),
2204
+ total,
2205
+ passed,
2206
+ failed,
2207
+ hasP0
2208
+ };
2209
+ }
2210
+ function formatScoreForCli(rs) {
2211
+ const gradeColor = rs.grade === "A" ? pc.green : rs.grade === "B" ? pc.yellow : rs.grade === "C" ? pc.red : pc.red;
2212
+ return gradeColor(`Score: ${rs.score}/100 (${rs.grade})`);
2213
+ }
2184
2214
 
2185
- export { BASELINE_SCHEMA_VERSION, CLIError, ErrorCodes, ErrorMessages, ErrorRemediation, SUPPORTED_SCHEMA_RANGE, WAIVER_SCHEMA_VERSION, addToBaseline, addWaiver, attachFindingId, attachFindingIds, audit, buildTelemetry, calculateRelativeSeverity, categorizeFindings, checkCloudHealth, clearAggregateCache, correlateFindings, evaluateCloud, extractIdentityPayload, fetchAggregateCalibration, formatAggregateCalibrationSummary, formatCorrelatedFinding, formatCorrelationStats, generateFindingId, generateTestSkeleton, getCIExitCode, getCISummary, getCloudInvariants, getCurrentSchemaVersion, getExpiringWaivers, getFrameworkBaseline, getSkippedPatterns, getStaffQuestion, getValidWaiver, getVerifiedCorrelations, hasCollisions, isAggregateCalibrationDisabled, isCLIError, isCloudEvalAvailable, isInBaseline, isTelemetryDisabled, loadBaseline, loadWaivers, pruneBaseline, pruneExpiredWaivers, reportCorrelationFeedback, reportCorrelations, reportTelemetry, resolveCollisions, saveBaseline, saveWaivers, shouldSkipPattern, validateSchemaVersion, wrapError };
2215
+ export { BASELINE_SCHEMA_VERSION, CLIError, ErrorCodes, ErrorMessages, ErrorRemediation, SUPPORTED_SCHEMA_RANGE, WAIVER_SCHEMA_VERSION, addToBaseline, addWaiver, attachFindingId, attachFindingIds, audit, buildTelemetry, calculateRelativeSeverity, categorizeFindings, checkCloudHealth, clearAggregateCache, computeReadinessScore, correlateFindings, evaluateCloud, extractIdentityPayload, fetchAggregateCalibration, formatAggregateCalibrationSummary, formatCorrelatedFinding, formatCorrelationStats, formatScoreForCli, generateFindingId, generateTestSkeleton, getCIExitCode, getCISummary, getCloudInvariants, getCurrentSchemaVersion, getExpiringWaivers, getFrameworkBaseline, getScoreGrade, getSkippedPatterns, getStaffQuestion, getValidWaiver, getVerifiedCorrelations, hasCollisions, isAggregateCalibrationDisabled, isCLIError, isCloudEvalAvailable, isInBaseline, isTelemetryDisabled, loadBaseline, loadWaivers, pruneBaseline, pruneExpiredWaivers, reportCorrelationFeedback, reportCorrelations, reportTelemetry, resolveCollisions, saveBaseline, saveWaivers, shouldSkipPattern, validateSchemaVersion, wrapError };
2186
2216
  //# sourceMappingURL=lib.js.map
2187
2217
  //# sourceMappingURL=lib.js.map