mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Merge pull request #250 from AikidoSec/bug/py-flag-warning
Emit deprecation warning when --include-python flag is used
This commit is contained in:
commit
9db8a2cc24
5 changed files with 107 additions and 2 deletions
|
|
@ -3,7 +3,8 @@
|
||||||
# Usage with "iex (iwr {url} -UseBasicParsing)" --> See README.md
|
# Usage with "iex (iwr {url} -UseBasicParsing)" --> See README.md
|
||||||
|
|
||||||
param(
|
param(
|
||||||
[switch]$ci
|
[switch]$ci,
|
||||||
|
[switch]$includepython
|
||||||
)
|
)
|
||||||
|
|
||||||
$Version = $env:SAFE_CHAIN_VERSION # Will be fetched from latest release if not set
|
$Version = $env:SAFE_CHAIN_VERSION # Will be fetched from latest release if not set
|
||||||
|
|
@ -119,6 +120,9 @@ function Install-SafeChain {
|
||||||
if ($ci) {
|
if ($ci) {
|
||||||
$installMsg += " in ci"
|
$installMsg += " in ci"
|
||||||
}
|
}
|
||||||
|
if ($includepython) {
|
||||||
|
Write-Warn "-includepython is deprecated and ignored. Python ecosystem is now included by default."
|
||||||
|
}
|
||||||
|
|
||||||
Write-Info $installMsg
|
Write-Info $installMsg
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,9 @@ parse_arguments() {
|
||||||
--ci)
|
--ci)
|
||||||
USE_CI_SETUP=true
|
USE_CI_SETUP=true
|
||||||
;;
|
;;
|
||||||
|
--include-python)
|
||||||
|
warn "--include-python is deprecated and ignored. Python ecosystem is now included by default."
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
error "Unknown argument: $arg"
|
error "Unknown argument: $arg"
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { ui } from "../environment/userInteraction.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {{loggingLevel: string | undefined, skipMinimumPackageAge: boolean | undefined, minimumPackageAgeHours: string | undefined}}
|
* @type {{loggingLevel: string | undefined, skipMinimumPackageAge: boolean | undefined, minimumPackageAgeHours: string | undefined}}
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,7 +35,7 @@ export function initializeCliArguments(args) {
|
||||||
setLoggingLevel(safeChainArgs);
|
setLoggingLevel(safeChainArgs);
|
||||||
setSkipMinimumPackageAge(safeChainArgs);
|
setSkipMinimumPackageAge(safeChainArgs);
|
||||||
setMinimumPackageAgeHours(safeChainArgs);
|
setMinimumPackageAgeHours(safeChainArgs);
|
||||||
|
checkDeprecatedPythonFlag(args);
|
||||||
return remainingArgs;
|
return remainingArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,3 +122,17 @@ function hasFlagArg(args, flagName) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits a deprecation warning for legacy --include-python flag
|
||||||
|
*
|
||||||
|
* @param {string[]} args
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
export function checkDeprecatedPythonFlag(args) {
|
||||||
|
if (hasFlagArg(args, "--include-python")) {
|
||||||
|
ui.writeWarning(
|
||||||
|
"--include-python is deprecated and ignored. Python tooling is included by default."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import {
|
||||||
getSkipMinimumPackageAge,
|
getSkipMinimumPackageAge,
|
||||||
getMinimumPackageAgeHours,
|
getMinimumPackageAgeHours,
|
||||||
} from "./cliArguments.js";
|
} from "./cliArguments.js";
|
||||||
|
import { ui } from "../environment/userInteraction.js";
|
||||||
|
|
||||||
describe("initializeCliArguments", () => {
|
describe("initializeCliArguments", () => {
|
||||||
it("should return all args when no safe-chain args are present", () => {
|
it("should return all args when no safe-chain args are present", () => {
|
||||||
|
|
@ -271,4 +272,40 @@ describe("initializeCliArguments", () => {
|
||||||
|
|
||||||
assert.strictEqual(getMinimumPackageAgeHours(), "-24");
|
assert.strictEqual(getMinimumPackageAgeHours(), "-24");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should warn on deprecated --include-python for setup", () => {
|
||||||
|
const warnings = [];
|
||||||
|
const originalWriteWarning = ui.writeWarning;
|
||||||
|
ui.writeWarning = (msg, ..._rest) => {
|
||||||
|
warnings.push(String(msg));
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const argv = ["node", "safe-chain", "setup", "--include-python"];
|
||||||
|
initializeCliArguments(argv);
|
||||||
|
assert.ok(
|
||||||
|
warnings.some((m) => m.includes("--include-python is deprecated")),
|
||||||
|
"Expected a deprecation warning for --include-python in setup"
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
ui.writeWarning = originalWriteWarning;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should warn on deprecated --include-python for setup-ci", () => {
|
||||||
|
const warnings = [];
|
||||||
|
const originalWriteWarning = ui.writeWarning;
|
||||||
|
ui.writeWarning = (msg, ..._rest) => {
|
||||||
|
warnings.push(String(msg));
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const argv = ["node", "safe-chain", "setup-ci", "--include-python"];
|
||||||
|
initializeCliArguments(argv);
|
||||||
|
assert.ok(
|
||||||
|
warnings.some((m) => m.includes("--include-python is deprecated")),
|
||||||
|
"Expected a deprecation warning for --include-python in setup-ci"
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
ui.writeWarning = originalWriteWarning;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
45
test/e2e/include-python-deprecation.e2e.spec.js
Normal file
45
test/e2e/include-python-deprecation.e2e.spec.js
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { describe, it, before, beforeEach, afterEach } from "node:test";
|
||||||
|
import { DockerTestContainer } from "./DockerTestContainer.js";
|
||||||
|
import assert from "node:assert";
|
||||||
|
|
||||||
|
describe("E2E: deprecated --include-python handling", () => {
|
||||||
|
let container;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
DockerTestContainer.buildImage();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
container = new DockerTestContainer();
|
||||||
|
await container.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
if (container) {
|
||||||
|
await container.stop();
|
||||||
|
container = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let shell of ["bash", "zsh"]) {
|
||||||
|
it(`safe-chain setup warns and continues for ${shell}`, async () => {
|
||||||
|
const sh = await container.openShell(shell);
|
||||||
|
const result = await sh.runCommand("safe-chain setup --include-python");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
result.output.toLowerCase().includes("deprecated and ignored"),
|
||||||
|
`Expected warning about deprecated --include-python. Output was:\n${result.output}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`safe-chain setup-ci warns and continues for ${shell}`, async () => {
|
||||||
|
const sh = await container.openShell(shell);
|
||||||
|
const result = await sh.runCommand("safe-chain setup-ci --include-python");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
result.output.toLowerCase().includes("deprecated and ignored"),
|
||||||
|
`Expected warning about deprecated --include-python. Output was:\n${result.output}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue