mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Implement basic bun security scanner for safe chain
This commit is contained in:
parent
8450b80223
commit
dc3ab32078
6 changed files with 420 additions and 1 deletions
37
packages/safe-chain-bun/src/index.js
Normal file
37
packages/safe-chain-bun/src/index.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { auditChanges } from "@aikidosec/safe-chain/scanning";
|
||||
|
||||
// Bun Security Scanner for Safe-Chain
|
||||
// This is the entry point for Bun's native security scanner integration
|
||||
|
||||
export const scanner = {
|
||||
version: "1", // Our scanner is using version 1 of the bun security scanner API.
|
||||
|
||||
async scan({ packages }) {
|
||||
const advisories = [];
|
||||
|
||||
try {
|
||||
const changes = packages.map((pkg) => ({
|
||||
name: pkg.name,
|
||||
version: pkg.version,
|
||||
type: "add",
|
||||
}));
|
||||
|
||||
const audit = await auditChanges(changes);
|
||||
|
||||
if (!audit.isAllowed) {
|
||||
for (const change of audit.disallowedChanges) {
|
||||
advisories.push({
|
||||
level: "fatal", // Fatal will block the installation process, this is what we want for packages that contain malware.
|
||||
package: change.name,
|
||||
url: null,
|
||||
description: `Package ${change.name}@${change.version} contains known security threats (${change.reason}). Installation blocked by Safe-Chain.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Safe-Chain security scan failed: ${error.message}`);
|
||||
}
|
||||
|
||||
return advisories;
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue