opena2a-cli 0.1.0 → 0.1.2
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/README.md +280 -0
- package/dist/adapters/registry.js +1 -1
- package/dist/adapters/registry.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +78 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/protect.d.ts +2 -0
- package/dist/commands/protect.d.ts.map +1 -1
- package/dist/commands/protect.js +56 -10
- package/dist/commands/protect.js.map +1 -1
- package/dist/commands/runtime.d.ts +1 -1
- package/dist/commands/runtime.js +5 -5
- package/dist/commands/runtime.js.map +1 -1
- package/dist/commands/self-register.js +6 -6
- package/dist/commands/self-register.js.map +1 -1
- package/dist/commands/shield.d.ts +36 -0
- package/dist/commands/shield.d.ts.map +1 -0
- package/dist/commands/shield.js +834 -0
- package/dist/commands/shield.js.map +1 -0
- package/dist/commands/verify.js +1 -1
- package/dist/commands/verify.js.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/shield/detect.d.ts +18 -0
- package/dist/shield/detect.d.ts.map +1 -0
- package/dist/shield/detect.js +402 -0
- package/dist/shield/detect.js.map +1 -0
- package/dist/shield/events.d.ts +65 -0
- package/dist/shield/events.d.ts.map +1 -0
- package/dist/shield/events.js +342 -0
- package/dist/shield/events.js.map +1 -0
- package/dist/shield/init.d.ts +22 -0
- package/dist/shield/init.d.ts.map +1 -0
- package/dist/shield/init.js +290 -0
- package/dist/shield/init.js.map +1 -0
- package/dist/shield/integrity.d.ts +75 -0
- package/dist/shield/integrity.d.ts.map +1 -0
- package/dist/shield/integrity.js +435 -0
- package/dist/shield/integrity.js.map +1 -0
- package/dist/shield/llm-backend.d.ts +36 -0
- package/dist/shield/llm-backend.d.ts.map +1 -0
- package/dist/shield/llm-backend.js +145 -0
- package/dist/shield/llm-backend.js.map +1 -0
- package/dist/shield/llm.d.ts +116 -0
- package/dist/shield/llm.d.ts.map +1 -0
- package/dist/shield/llm.js +536 -0
- package/dist/shield/llm.js.map +1 -0
- package/dist/shield/policy.d.ts +70 -0
- package/dist/shield/policy.d.ts.map +1 -0
- package/dist/shield/policy.js +399 -0
- package/dist/shield/policy.js.map +1 -0
- package/dist/shield/session.d.ts +63 -0
- package/dist/shield/session.d.ts.map +1 -0
- package/dist/shield/session.js +242 -0
- package/dist/shield/session.js.map +1 -0
- package/dist/shield/signing.d.ts +41 -0
- package/dist/shield/signing.d.ts.map +1 -0
- package/dist/shield/signing.js +161 -0
- package/dist/shield/signing.js.map +1 -0
- package/dist/shield/status.d.ts +4 -0
- package/dist/shield/status.d.ts.map +1 -0
- package/dist/shield/status.js +241 -0
- package/dist/shield/status.js.map +1 -0
- package/dist/shield/types.d.ts +398 -0
- package/dist/shield/types.d.ts.map +1 -0
- package/dist/shield/types.js +31 -0
- package/dist/shield/types.js.map +1 -0
- package/dist/util/drift-liveness.d.ts +37 -0
- package/dist/util/drift-liveness.d.ts.map +1 -0
- package/dist/util/drift-liveness.js +114 -0
- package/dist/util/drift-liveness.js.map +1 -0
- package/dist/util/drift-verification.d.ts +60 -0
- package/dist/util/drift-verification.d.ts.map +1 -0
- package/dist/util/drift-verification.js +457 -0
- package/dist/util/drift-verification.js.map +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Shield: Unified Developer Workstation Security Orchestration
|
|
3
|
+
// All TypeScript interfaces for the Shield module.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.EVALUATE_BUDGET_MS = exports.SESSION_TIMEOUT_MS = exports.LEARN_PHASE_MIN_SESSIONS = exports.LEARN_PHASE_MIN_ACTIONS = exports.STABILITY_WINDOW_SESSIONS = exports.STABILITY_THRESHOLD = exports.MAX_EVENTS_FILE_SIZE = exports.LLM_CACHE_TTL_TRIAGE = exports.LLM_CACHE_TTL_NARRATIVE = exports.LLM_CACHE_TTL_ANOMALY = exports.LLM_CACHE_TTL_POLICY = exports.SHIELD_LLM_CACHE_FILE = exports.SHIELD_REPORTS_DIR = exports.SHIELD_BASELINES_DIR = exports.SHIELD_CONFIG_FILE = exports.SHIELD_SCAN_FILE = exports.SHIELD_POLICY_CACHE = exports.SHIELD_POLICY_FILE = exports.SHIELD_EVENTS_FILE = exports.SHIELD_SIGNATURES_FILE = exports.SHIELD_DIR = void 0;
|
|
6
|
+
// --- Constants ---
|
|
7
|
+
exports.SHIELD_DIR = '.opena2a/shield';
|
|
8
|
+
exports.SHIELD_SIGNATURES_FILE = 'signatures.json';
|
|
9
|
+
exports.SHIELD_EVENTS_FILE = 'events.jsonl';
|
|
10
|
+
exports.SHIELD_POLICY_FILE = 'policy.yaml';
|
|
11
|
+
exports.SHIELD_POLICY_CACHE = 'policy-cache.json';
|
|
12
|
+
exports.SHIELD_SCAN_FILE = 'scan.json';
|
|
13
|
+
exports.SHIELD_CONFIG_FILE = 'config.json';
|
|
14
|
+
exports.SHIELD_BASELINES_DIR = 'baselines';
|
|
15
|
+
exports.SHIELD_REPORTS_DIR = 'reports';
|
|
16
|
+
exports.SHIELD_LLM_CACHE_FILE = 'llm-cache.json';
|
|
17
|
+
// LLM cache TTLs (milliseconds)
|
|
18
|
+
exports.LLM_CACHE_TTL_POLICY = 24 * 60 * 60 * 1000; // 24h
|
|
19
|
+
exports.LLM_CACHE_TTL_ANOMALY = 7 * 24 * 60 * 60 * 1000; // 7d
|
|
20
|
+
exports.LLM_CACHE_TTL_NARRATIVE = 30 * 24 * 60 * 60 * 1000; // 30d (per report)
|
|
21
|
+
exports.LLM_CACHE_TTL_TRIAGE = 60 * 60 * 1000; // 1h
|
|
22
|
+
exports.MAX_EVENTS_FILE_SIZE = 10 * 1024 * 1024; // 10MB
|
|
23
|
+
// Adaptive enforcement: continuous learning, not timer-based.
|
|
24
|
+
// Suggestions appear when behavior stabilizes, not after a fixed period.
|
|
25
|
+
exports.STABILITY_THRESHOLD = 0.8; // suggest policy when stability >= this
|
|
26
|
+
exports.STABILITY_WINDOW_SESSIONS = 5; // sessions without new behavior = stable
|
|
27
|
+
exports.LEARN_PHASE_MIN_ACTIONS = 50; // minimum actions before stability is checked
|
|
28
|
+
exports.LEARN_PHASE_MIN_SESSIONS = 3; // minimum sessions before stability is checked
|
|
29
|
+
exports.SESSION_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
|
|
30
|
+
exports.EVALUATE_BUDGET_MS = 50;
|
|
31
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shield/types.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,mDAAmD;;;AAgdnD,oBAAoB;AAEP,QAAA,UAAU,GAAG,iBAAiB,CAAC;AAC/B,QAAA,sBAAsB,GAAG,iBAAiB,CAAC;AAC3C,QAAA,kBAAkB,GAAG,cAAc,CAAC;AACpC,QAAA,kBAAkB,GAAG,aAAa,CAAC;AACnC,QAAA,mBAAmB,GAAG,mBAAmB,CAAC;AAC1C,QAAA,gBAAgB,GAAG,WAAW,CAAC;AAC/B,QAAA,kBAAkB,GAAG,aAAa,CAAC;AACnC,QAAA,oBAAoB,GAAG,WAAW,CAAC;AACnC,QAAA,kBAAkB,GAAG,SAAS,CAAC;AAC/B,QAAA,qBAAqB,GAAG,gBAAgB,CAAC;AAEtD,gCAAgC;AACnB,QAAA,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAM,MAAM;AACvD,QAAA,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,KAAK;AACtD,QAAA,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,mBAAmB;AACvE,QAAA,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAY,KAAK;AAEvD,QAAA,oBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO;AAE7D,8DAA8D;AAC9D,yEAAyE;AAC5D,QAAA,mBAAmB,GAAG,GAAG,CAAC,CAAC,wCAAwC;AACnE,QAAA,yBAAyB,GAAG,CAAC,CAAC,CAAC,yCAAyC;AACxE,QAAA,uBAAuB,GAAG,EAAE,CAAC,CAAC,8CAA8C;AAC5E,QAAA,wBAAwB,GAAG,CAAC,CAAC,CAAC,+CAA+C;AAE7E,QAAA,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAClD,QAAA,kBAAkB,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drift liveness verification — confirms whether a detected credential
|
|
3
|
+
* actually grants access to AI/ML services (scope drift).
|
|
4
|
+
*
|
|
5
|
+
* DRIFT-001: Google API Key -> Gemini Generative Language API
|
|
6
|
+
* DRIFT-002: AWS Access Key -> no liveness check (requires secret key)
|
|
7
|
+
*/
|
|
8
|
+
export interface LivenessResult {
|
|
9
|
+
/** Whether the credential confirmed access to the AI service */
|
|
10
|
+
confirmed: boolean;
|
|
11
|
+
/** HTTP status code from the verification request */
|
|
12
|
+
statusCode?: number;
|
|
13
|
+
/** Human-readable detail (e.g., model names found) */
|
|
14
|
+
details?: string;
|
|
15
|
+
/** Error message if the check failed to complete */
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Timeout for each liveness HTTP request (ms) */
|
|
19
|
+
export declare const LIVENESS_TIMEOUT = 5000;
|
|
20
|
+
/** Delay between consecutive liveness checks to avoid rate limiting (ms) */
|
|
21
|
+
export declare const LIVENESS_DELAY = 500;
|
|
22
|
+
/** Maximum number of liveness checks per scan run */
|
|
23
|
+
export declare const MAX_LIVENESS_CHECKS = 5;
|
|
24
|
+
/**
|
|
25
|
+
* Verify whether a Google API key grants access to the Gemini Generative
|
|
26
|
+
* Language API by listing available models.
|
|
27
|
+
*
|
|
28
|
+
* GET {baseUrl}/v1beta/models?key={KEY}
|
|
29
|
+
* - 200 with model list -> confirmed (scope drift to AI)
|
|
30
|
+
* - 401/403 -> not confirmed (key restricted)
|
|
31
|
+
* - timeout/error -> not confirmed (inconclusive)
|
|
32
|
+
*
|
|
33
|
+
* @param apiKey The Google API key value
|
|
34
|
+
* @param baseUrl Override for testing (default: generativelanguage.googleapis.com)
|
|
35
|
+
*/
|
|
36
|
+
export declare function verifyGeminiAccess(apiKey: string, baseUrl?: string): Promise<LivenessResult>;
|
|
37
|
+
//# sourceMappingURL=drift-liveness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift-liveness.d.ts","sourceRoot":"","sources":["../../src/util/drift-liveness.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,SAAS,EAAE,OAAO,CAAC;IACnB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,4EAA4E;AAC5E,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAIrC;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,CAmDzB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Drift liveness verification — confirms whether a detected credential
|
|
4
|
+
* actually grants access to AI/ML services (scope drift).
|
|
5
|
+
*
|
|
6
|
+
* DRIFT-001: Google API Key -> Gemini Generative Language API
|
|
7
|
+
* DRIFT-002: AWS Access Key -> no liveness check (requires secret key)
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.MAX_LIVENESS_CHECKS = exports.LIVENESS_DELAY = exports.LIVENESS_TIMEOUT = void 0;
|
|
44
|
+
exports.verifyGeminiAccess = verifyGeminiAccess;
|
|
45
|
+
const https = __importStar(require("node:https"));
|
|
46
|
+
const http = __importStar(require("node:http"));
|
|
47
|
+
// --- Constants ---
|
|
48
|
+
/** Timeout for each liveness HTTP request (ms) */
|
|
49
|
+
exports.LIVENESS_TIMEOUT = 5000;
|
|
50
|
+
/** Delay between consecutive liveness checks to avoid rate limiting (ms) */
|
|
51
|
+
exports.LIVENESS_DELAY = 500;
|
|
52
|
+
/** Maximum number of liveness checks per scan run */
|
|
53
|
+
exports.MAX_LIVENESS_CHECKS = 5;
|
|
54
|
+
// --- Gemini liveness ---
|
|
55
|
+
/**
|
|
56
|
+
* Verify whether a Google API key grants access to the Gemini Generative
|
|
57
|
+
* Language API by listing available models.
|
|
58
|
+
*
|
|
59
|
+
* GET {baseUrl}/v1beta/models?key={KEY}
|
|
60
|
+
* - 200 with model list -> confirmed (scope drift to AI)
|
|
61
|
+
* - 401/403 -> not confirmed (key restricted)
|
|
62
|
+
* - timeout/error -> not confirmed (inconclusive)
|
|
63
|
+
*
|
|
64
|
+
* @param apiKey The Google API key value
|
|
65
|
+
* @param baseUrl Override for testing (default: generativelanguage.googleapis.com)
|
|
66
|
+
*/
|
|
67
|
+
function verifyGeminiAccess(apiKey, baseUrl) {
|
|
68
|
+
const host = baseUrl ?? 'https://generativelanguage.googleapis.com';
|
|
69
|
+
const url = `${host}/v1beta/models?key=${apiKey}`;
|
|
70
|
+
return new Promise((resolve) => {
|
|
71
|
+
const transport = url.startsWith('https') ? https : http;
|
|
72
|
+
const req = transport.get(url, { timeout: exports.LIVENESS_TIMEOUT }, (res) => {
|
|
73
|
+
const chunks = [];
|
|
74
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
75
|
+
res.on('end', () => {
|
|
76
|
+
const statusCode = res.statusCode ?? 0;
|
|
77
|
+
if (statusCode === 200) {
|
|
78
|
+
try {
|
|
79
|
+
const body = JSON.parse(Buffer.concat(chunks).toString('utf-8'));
|
|
80
|
+
const models = (body.models ?? [])
|
|
81
|
+
.slice(0, 3)
|
|
82
|
+
.map((m) => m.name ?? 'unknown');
|
|
83
|
+
resolve({
|
|
84
|
+
confirmed: true,
|
|
85
|
+
statusCode,
|
|
86
|
+
details: `Active Gemini access: ${models.join(', ')}`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
resolve({
|
|
91
|
+
confirmed: true,
|
|
92
|
+
statusCode,
|
|
93
|
+
details: 'Active Gemini access (response parsed partially)',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
resolve({
|
|
99
|
+
confirmed: false,
|
|
100
|
+
statusCode,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
req.on('timeout', () => {
|
|
106
|
+
req.destroy();
|
|
107
|
+
resolve({ confirmed: false, error: 'Liveness check timed out' });
|
|
108
|
+
});
|
|
109
|
+
req.on('error', (err) => {
|
|
110
|
+
resolve({ confirmed: false, error: err.message });
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=drift-liveness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift-liveness.js","sourceRoot":"","sources":["../../src/util/drift-liveness.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CH,gDAsDC;AA/FD,kDAAoC;AACpC,gDAAkC;AAelC,oBAAoB;AAEpB,kDAAkD;AACrC,QAAA,gBAAgB,GAAG,IAAI,CAAC;AAErC,4EAA4E;AAC/D,QAAA,cAAc,GAAG,GAAG,CAAC;AAElC,qDAAqD;AACxC,QAAA,mBAAmB,GAAG,CAAC,CAAC;AAErC,0BAA0B;AAE1B;;;;;;;;;;;GAWG;AACH,SAAgB,kBAAkB,CAChC,MAAc,EACd,OAAgB;IAEhB,MAAM,IAAI,GAAG,OAAO,IAAI,2CAA2C,CAAC;IACpE,MAAM,GAAG,GAAG,GAAG,IAAI,sBAAsB,MAAM,EAAE,CAAC;IAElD,OAAO,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;QAC7C,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAEzD,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,wBAAgB,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;YACpE,MAAM,MAAM,GAAa,EAAE,CAAC;YAE5B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAEtD,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBACjB,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC;gBAEvC,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;oBACvB,IAAI,CAAC;wBACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;wBACjE,MAAM,MAAM,GAAa,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;6BACzC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;6BACX,GAAG,CAAC,CAAC,CAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,SAAS,CAAC,CAAC;wBACtD,OAAO,CAAC;4BACN,SAAS,EAAE,IAAI;4BACf,UAAU;4BACV,OAAO,EAAE,yBAAyB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;yBACtD,CAAC,CAAC;oBACL,CAAC;oBAAC,MAAM,CAAC;wBACP,OAAO,CAAC;4BACN,SAAS,EAAE,IAAI;4BACf,UAAU;4BACV,OAAO,EAAE,kDAAkD;yBAC5D,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC;wBACN,SAAS,EAAE,KAAK;wBAChB,UAAU;qBACX,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACrB,GAAG,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,EAAE;YAC7B,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drift liveness verification.
|
|
3
|
+
*
|
|
4
|
+
* After pattern matching detects a credential (e.g., DRIFT-001 Google API key),
|
|
5
|
+
* this module performs an actual API call to verify whether the credential has
|
|
6
|
+
* drifted capabilities (e.g., Gemini access on a Maps key).
|
|
7
|
+
*
|
|
8
|
+
* Liveness checks are opt-in, non-blocking, and timeout after 5 seconds.
|
|
9
|
+
*/
|
|
10
|
+
import type { CredentialMatch } from './credential-patterns.js';
|
|
11
|
+
export interface LivenessResult {
|
|
12
|
+
/** Finding ID (e.g., "DRIFT-001") */
|
|
13
|
+
findingId: string;
|
|
14
|
+
/** Whether liveness verification was attempted */
|
|
15
|
+
checked: boolean;
|
|
16
|
+
/** Whether the drifted capability is confirmed live */
|
|
17
|
+
live: boolean;
|
|
18
|
+
/** Original severity before verification */
|
|
19
|
+
originalSeverity: string;
|
|
20
|
+
/** Escalated severity (if live) */
|
|
21
|
+
escalatedSeverity: string;
|
|
22
|
+
/** Human-readable detail about the verification result */
|
|
23
|
+
detail: string;
|
|
24
|
+
/** Error message if the check failed */
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Verify whether a Google API key has active Gemini access by calling
|
|
29
|
+
* the Generative Language API's models endpoint.
|
|
30
|
+
*
|
|
31
|
+
* - 200: Key has Gemini access (drift confirmed)
|
|
32
|
+
* - 403/401/400: No Gemini access or key invalid
|
|
33
|
+
* - Network error: Inconclusive
|
|
34
|
+
*/
|
|
35
|
+
export declare function verifyGeminiAccess(apiKey: string): Promise<LivenessResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Verify whether an AWS access key is live and has Bedrock access.
|
|
38
|
+
*
|
|
39
|
+
* Step 1: STS GetCallerIdentity -- confirms key is live (always works, zero permissions needed).
|
|
40
|
+
* Step 2: If live, try ListFoundationModels to check Bedrock access.
|
|
41
|
+
*
|
|
42
|
+
* AWS SigV4 signing is done manually -- no SDK dependency.
|
|
43
|
+
* Requires the secret key to be found alongside the access key.
|
|
44
|
+
*/
|
|
45
|
+
export declare function verifyBedrockAccess(accessKeyId: string, secretAccessKey?: string): Promise<LivenessResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Run liveness verification on all DRIFT-prefixed credential matches.
|
|
48
|
+
* Returns a map of credential value -> LivenessResult.
|
|
49
|
+
*
|
|
50
|
+
* Runs checks in parallel with a concurrency limit of 3.
|
|
51
|
+
*/
|
|
52
|
+
export declare function verifyDriftFindings(matches: CredentialMatch[]): Promise<Map<string, LivenessResult>>;
|
|
53
|
+
/**
|
|
54
|
+
* Apply liveness results to credential matches: escalate severity
|
|
55
|
+
* and update explanation text for confirmed drift.
|
|
56
|
+
*
|
|
57
|
+
* Returns new match objects (does not mutate originals).
|
|
58
|
+
*/
|
|
59
|
+
export declare function applyLivenessResults(matches: CredentialMatch[], livenessResults: Map<string, LivenessResult>): CredentialMatch[];
|
|
60
|
+
//# sourceMappingURL=drift-verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift-verification.d.ts","sourceRoot":"","sources":["../../src/util/drift-verification.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIhE,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,OAAO,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,IAAI,EAAE,OAAO,CAAC;IACd,4CAA4C;IAC5C,gBAAgB,EAAE,MAAM,CAAC;IACzB,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAUD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAyDhF;AA+PD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,cAAc,CAAC,CAwEzB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,eAAe,EAAE,GACzB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAmDtC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,eAAe,EAAE,EAC1B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAC3C,eAAe,EAAE,CA2BnB"}
|