Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
lib
/runner
src/plugins.ts
.claude/

# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node
Expand Down
24 changes: 23 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83059,7 +83059,7 @@ function main() {
yield (0, plugins_1.registerPlugins)(enablePlugins, tool.version);
}
catch (err) {
core.setFailed(err.message);
core.setFailed(err instanceof Error ? err.message : String(err));
}
});
}
Expand Down Expand Up @@ -83090,6 +83090,25 @@ exports.registerPlugins = registerPlugins;
const shelljs_1 = __importDefault(__nccwpck_require__(1271));
const semver_1 = __importDefault(__nccwpck_require__(2597));
const node_fs_1 = __nccwpck_require__(3024);
/**
* Validates enablePlugins input to prevent command injection.
* Allows: 'true', 'false', or comma-separated plugin names (alphanumeric, underscore only).
*/
function validatePluginInput(input) {
// Allow 'true', 'false', or comma-separated identifiers (word characters only)
if (!/^(true|false|[\w]+(,[\w]+)*)$/i.test(input)) {
throw new Error(`Invalid enable-plugins input: "${input}". Only alphanumeric characters, underscores, and commas are allowed.`);
}
}
/**
* Validates version string to prevent command injection.
* Allows: alphanumeric, dots, hyphens (e.g., "0.95.0", "nightly-56ed69a").
*/
function validateVersion(version) {
if (!/^[\w.-]+$/.test(version)) {
throw new Error(`Invalid version format: "${version}". Only alphanumeric characters, dots, and hyphens are allowed.`);
}
}
const nu = String.raw;
const pluginRegisterScript = nu `
#!/usr/bin/env nu
Expand Down Expand Up @@ -83159,6 +83178,9 @@ function registerPlugins(enablePlugins, version) {
if (enablePlugins === '' || enablePlugins === 'false') {
return;
}
// Validate inputs to prevent command injection
validatePluginInput(enablePlugins);
validateVersion(version);
const LEGACY_VERSION = '0.92.3';
const script = 'register-plugins.nu';
const isLegacyVersion = !version.includes('nightly') && semver_1.default.lte(version, LEGACY_VERSION);
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function main() {
console.log(`Current directory: ${process.cwd()}`);
await registerPlugins(enablePlugins, tool.version);
} catch (err) {
core.setFailed(err.message);
core.setFailed(err instanceof Error ? err.message : String(err));
}
}

Expand Down
30 changes: 30 additions & 0 deletions src/plugins-tpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@ import shell from 'shelljs';
import semver from 'semver';
import { promises as fs, constants as fs_constants } from 'node:fs';

/**
* Validates enablePlugins input to prevent command injection.
* Allows: 'true', 'false', or comma-separated plugin names (alphanumeric, underscore only).
*/
function validatePluginInput(input: string): void {
// Allow 'true', 'false', or comma-separated identifiers (word characters only)
if (!/^(true|false|[\w]+(,[\w]+)*)$/i.test(input)) {
throw new Error(
`Invalid enable-plugins input: "${input}". Only alphanumeric characters, underscores, and commas are allowed.`
);
}
}

/**
* Validates version string to prevent command injection.
* Allows: alphanumeric, dots, hyphens (e.g., "0.95.0", "nightly-56ed69a").
*/
function validateVersion(version: string): void {
if (!/^[\w.-]+$/.test(version)) {
throw new Error(
`Invalid version format: "${version}". Only alphanumeric characters, dots, and hyphens are allowed.`
);
}
}

const nu = String.raw;

const pluginRegisterScript = nu`
Expand All @@ -12,6 +37,11 @@ export async function registerPlugins(enablePlugins: string, version: string) {
if (enablePlugins === '' || enablePlugins === 'false') {
return;
}

// Validate inputs to prevent command injection
validatePluginInput(enablePlugins);
validateVersion(version);

const LEGACY_VERSION = '0.92.3';
const script = 'register-plugins.nu';
const isLegacyVersion = !version.includes('nightly') && semver.lte(version, LEGACY_VERSION);
Expand Down
30 changes: 30 additions & 0 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@ import shell from 'shelljs';
import semver from 'semver';
import { promises as fs, constants as fs_constants } from 'node:fs';

/**
* Validates enablePlugins input to prevent command injection.
* Allows: 'true', 'false', or comma-separated plugin names (alphanumeric, underscore only).
*/
function validatePluginInput(input: string): void {
// Allow 'true', 'false', or comma-separated identifiers (word characters only)
if (!/^(true|false|[\w]+(,[\w]+)*)$/i.test(input)) {
throw new Error(
`Invalid enable-plugins input: "${input}". Only alphanumeric characters, underscores, and commas are allowed.`
);
}
}

/**
* Validates version string to prevent command injection.
* Allows: alphanumeric, dots, hyphens (e.g., "0.95.0", "nightly-56ed69a").
*/
function validateVersion(version: string): void {
if (!/^[\w.-]+$/.test(version)) {
throw new Error(
`Invalid version format: "${version}". Only alphanumeric characters, dots, and hyphens are allowed.`
);
}
}

const nu = String.raw;

const pluginRegisterScript = nu`
Expand Down Expand Up @@ -72,6 +97,11 @@ export async function registerPlugins(enablePlugins: string, version: string) {
if (enablePlugins === '' || enablePlugins === 'false') {
return;
}

// Validate inputs to prevent command injection
validatePluginInput(enablePlugins);
validateVersion(version);

const LEGACY_VERSION = '0.92.3';
const script = 'register-plugins.nu';
const isLegacyVersion = !version.includes('nightly') && semver.lte(version, LEGACY_VERSION);
Expand Down