mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Remove --safe-chain-malware-action flag
This commit is contained in:
parent
95d9cefcc9
commit
ab3319a310
6 changed files with 8 additions and 188 deletions
|
|
@ -1,10 +1,6 @@
|
|||
import { describe, it } from "node:test";
|
||||
import assert from "node:assert";
|
||||
import {
|
||||
initializeCliArguments,
|
||||
getMalwareAction,
|
||||
getLoggingLevel,
|
||||
} from "./cliArguments.js";
|
||||
import { initializeCliArguments, getLoggingLevel } from "./cliArguments.js";
|
||||
|
||||
describe("initializeCliArguments", () => {
|
||||
it("should return all args when no safe-chain args are present", () => {
|
||||
|
|
@ -61,55 +57,6 @@ describe("initializeCliArguments", () => {
|
|||
assert.deepEqual(result, ["install", "my--safe-chain-package", "--save"]);
|
||||
});
|
||||
|
||||
it("should not set malwareAction when no safe-chain arguments are passed", () => {
|
||||
const args = ["install", "express", "--save"];
|
||||
const result = initializeCliArguments(args);
|
||||
|
||||
assert.deepEqual(result, ["install", "express", "--save"]);
|
||||
assert.strictEqual(getMalwareAction(), undefined);
|
||||
});
|
||||
|
||||
it("should parse malware-action=block and set state", () => {
|
||||
const args = ["--safe-chain-malware-action=block", "install", "package"];
|
||||
const result = initializeCliArguments(args);
|
||||
|
||||
assert.deepEqual(result, ["install", "package"]);
|
||||
assert.strictEqual(getMalwareAction(), "block");
|
||||
});
|
||||
|
||||
it("should parse malware-action=prompt and set state", () => {
|
||||
const args = ["--safe-chain-malware-action=prompt", "install", "package"];
|
||||
const result = initializeCliArguments(args);
|
||||
|
||||
assert.deepEqual(result, ["install", "package"]);
|
||||
assert.strictEqual(getMalwareAction(), "prompt");
|
||||
});
|
||||
|
||||
it("should handle multiple malware-action args, using the last valid one", () => {
|
||||
const args = [
|
||||
"--safe-chain-malware-action=block",
|
||||
"--safe-chain-malware-action=prompt",
|
||||
"install",
|
||||
];
|
||||
const result = initializeCliArguments(args);
|
||||
|
||||
assert.deepEqual(result, ["install"]);
|
||||
assert.strictEqual(getMalwareAction(), "prompt");
|
||||
});
|
||||
|
||||
it("should handle malware-action with other safe-chain args", () => {
|
||||
const args = [
|
||||
"--safe-chain-debug",
|
||||
"--safe-chain-malware-action=block",
|
||||
"--safe-chain-verbose",
|
||||
"install",
|
||||
];
|
||||
const result = initializeCliArguments(args);
|
||||
|
||||
assert.deepEqual(result, ["install"]);
|
||||
assert.strictEqual(getMalwareAction(), "block");
|
||||
});
|
||||
|
||||
it("should not set loggingLevel when no logging argument is passed", () => {
|
||||
const args = ["install", "express", "--save"];
|
||||
initializeCliArguments(args);
|
||||
|
|
@ -170,6 +117,5 @@ describe("initializeCliArguments", () => {
|
|||
|
||||
assert.deepEqual(result, ["install"]);
|
||||
assert.strictEqual(getLoggingLevel(), "silent");
|
||||
assert.strictEqual(getMalwareAction(), "block");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue