From c72973d25e2248a7950bf4a2b977936c964281d1 Mon Sep 17 00:00:00 2001 From: Chad Bentz <1760475+felickz@users.noreply.github.com> Date: Fri, 7 Mar 2025 14:26:04 -0500 Subject: [PATCH] Do some silly changes to introduce vulns in a few projects --- .github/workflows/codeql-monorepo.yml | 2 +- packages/babel-cli/src/babel/dir.ts | 7 +++++++ packages/babel-helpers/src/index.ts | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql-monorepo.yml b/.github/workflows/codeql-monorepo.yml index 3b29a904a7..d81452e09c 100644 --- a/.github/workflows/codeql-monorepo.yml +++ b/.github/workflows/codeql-monorepo.yml @@ -87,7 +87,7 @@ jobs: project: ${{ fromJson(needs.changes.outputs.projects).projects }} steps: - name: Analyze code - uses: advanced-security/monorepo-code-scanning-action/scan@main + uses: advanced-security/monorepo-code-scanning-action/scan@annotate-sarif # If you have a custom analysis workflow defined at .github/workflows/custom-codeql-analysis.yml, then set this to 'true' so that it is run. # custom-analysis: true diff --git a/packages/babel-cli/src/babel/dir.ts b/packages/babel-cli/src/babel/dir.ts index b3f4fd6074..e691b10e39 100644 --- a/packages/babel-cli/src/babel/dir.ts +++ b/packages/babel-cli/src/babel/dir.ts @@ -18,6 +18,13 @@ function outputFileSync(filePath: string, data: string | Buffer): void { fs.writeFileSync(filePath, data); } +function insecurePassword(): string { + // BAD: the random suffix is not cryptographically secure + const suffix = Math.random(); + const password = "myPassword" + suffix; + return password; +} + export default async function ({ cliOptions, babelOptions, diff --git a/packages/babel-helpers/src/index.ts b/packages/babel-helpers/src/index.ts index be7b2c4198..958dae0b63 100644 --- a/packages/babel-helpers/src/index.ts +++ b/packages/babel-helpers/src/index.ts @@ -24,6 +24,13 @@ function deep(obj: any, path: string, value?: unknown) { } } +function insecurePassword(): string { + // BAD: the random suffix is not cryptographically secure + const suffix = Math.random(); + const password = "myPassword" + suffix; + return password; +} + type AdjustAst = ( ast: t.Program, exportName: string,