@synkro-sh/cli 1.4.55 → 1.4.56
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/bootstrap.js +55 -1
- package/dist/bootstrap.js.map +1 -1
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -2089,6 +2089,60 @@ async function main() {
|
|
|
2089
2089
|
if (!jwt) { outputEmpty(); return; }
|
|
2090
2090
|
jwt = await ensureFreshJwt(jwt);
|
|
2091
2091
|
|
|
2092
|
+
// \u2500\u2500\u2500 CVE scan for package install commands \u2500\u2500\u2500
|
|
2093
|
+
if (toolName === 'Bash') {
|
|
2094
|
+
const pkgInstallMatch = command.match(
|
|
2095
|
+
/(?:npm\\s+(?:install|i|add)|pnpm\\s+(?:add|install|i)|yarn\\s+add|bun\\s+(?:add|install|i)|pip\\s+install|pip3\\s+install|go\\s+get|cargo\\s+add|gem\\s+install|composer\\s+require)\\s+(.+)/
|
|
2096
|
+
);
|
|
2097
|
+
if (pkgInstallMatch) {
|
|
2098
|
+
const rawArgs = pkgInstallMatch[1];
|
|
2099
|
+
const deps: Record<string, string> = {};
|
|
2100
|
+
const tokens = rawArgs.split(/\\s+/);
|
|
2101
|
+
for (const token of tokens) {
|
|
2102
|
+
if (token.startsWith('-')) continue;
|
|
2103
|
+
const atIdx = token.lastIndexOf('@');
|
|
2104
|
+
if (atIdx > 0) {
|
|
2105
|
+
deps[token.slice(0, atIdx)] = token.slice(atIdx + 1);
|
|
2106
|
+
} else {
|
|
2107
|
+
deps[token] = '*';
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
if (Object.keys(deps).length > 0) {
|
|
2111
|
+
try {
|
|
2112
|
+
const cveBody = { file_path: 'package.json', content: JSON.stringify({ dependencies: deps }), dependencies: deps };
|
|
2113
|
+
const cveResp = await fetch(GATEWAY_URL + '/api/v1/cve-scan', {
|
|
2114
|
+
method: 'POST',
|
|
2115
|
+
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + jwt },
|
|
2116
|
+
body: JSON.stringify(cveBody),
|
|
2117
|
+
signal: AbortSignal.timeout(8000),
|
|
2118
|
+
}).then(r => r.json()) as any;
|
|
2119
|
+
|
|
2120
|
+
const findings = Array.isArray(cveResp?.findings) ? cveResp.findings : [];
|
|
2121
|
+
if (findings.length > 0) {
|
|
2122
|
+
const top3 = findings.slice(0, 3).map((f: any) => {
|
|
2123
|
+
const id = f.cve || f.id || '?';
|
|
2124
|
+
const pkg = f.package || '?';
|
|
2125
|
+
const ver = f.version || '?';
|
|
2126
|
+
const title = f.title || f.summary || 'vulnerable';
|
|
2127
|
+
return '[' + id + '] ' + pkg + '@' + ver + ': ' + title;
|
|
2128
|
+
}).join('; ');
|
|
2129
|
+
const count = findings.length;
|
|
2130
|
+
const label = count === 1 ? 'advisory' : 'advisories';
|
|
2131
|
+
const cveMsg = '[synkro:cveScan] ' + cmdShort + ' \\u2192 ' + count + ' ' + label;
|
|
2132
|
+
const ctx = 'CVE: ' + top3 + '\\nDo NOT install packages with known vulnerabilities. Use a patched version or a different package.';
|
|
2133
|
+
outputJson({
|
|
2134
|
+
systemMessage: cveMsg,
|
|
2135
|
+
hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: ctx, additionalContext: ctx },
|
|
2136
|
+
});
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
} catch (e) {
|
|
2140
|
+
log('bashGuard CVE check failed: ' + String(e));
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2092
2146
|
const transcript = extractTranscript(transcriptPath);
|
|
2093
2147
|
const lastPrompt = readLastPrompt();
|
|
2094
2148
|
|
|
@@ -5051,7 +5105,7 @@ function writeConfigEnv(opts) {
|
|
|
5051
5105
|
`SYNKRO_CREDENTIALS_PATH=${shellQuoteSingle(credsPath)}`,
|
|
5052
5106
|
`SYNKRO_TIER=${shellQuoteSingle(safeTier)}`,
|
|
5053
5107
|
`SYNKRO_INFERENCE=${shellQuoteSingle(safeInference)}`,
|
|
5054
|
-
`SYNKRO_VERSION=${shellQuoteSingle("1.4.
|
|
5108
|
+
`SYNKRO_VERSION=${shellQuoteSingle("1.4.56")}`
|
|
5055
5109
|
];
|
|
5056
5110
|
if (safeSynkroBin) lines.push(`SYNKRO_CLI_BIN=${shellQuoteSingle(safeSynkroBin)}`);
|
|
5057
5111
|
if (safeUserId) lines.push(`SYNKRO_USER_ID=${shellQuoteSingle(safeUserId)}`);
|