OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
ci: use a sparse checkout when cutting releases (#2023)
Michael D'Angeloa4d9f853a1f2
diff --git a/.github/workflows/node-release-cut.yml b/.github/workflows/node-release-cut.ymlindex 1149dfc10..e045f2f08 100644--- a/.github/workflows/node-release-cut.yml+++ b/.github/workflows/node-release-cut.yml@@ -45,6 +45,9 @@ jobs:uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:fetch-depth: 0+ sparse-checkout: |+ .github+ sdk/typescript/scriptspersist-credentials: falseref: ${{ github.event.workflow_run.head_sha || github.sha }}@@ -99,47 +102,45 @@ jobs:fiif [[ "$GITHUB_EVENT_NAME" == "workflow_run" ]] &&- previous_sha="$(git rev-parse "$RELEASE_SHA^" 2>/dev/null)"; then- if previous_manifest="$(git show "$previous_sha:sdk/typescript/package.json" 2>/dev/null)"; then- previous_version="$(- printf '%s\n' "$previous_manifest" |- node --input-type=module --eval '- import { readFileSync } from "node:fs";- const manifest = JSON.parse(readFileSync(0, "utf8"));- if (typeof manifest.version !== "string") {- throw new Error("The previous package version is missing.");- }- process.stdout.write(manifest.version);- '+ previous_manifest_oid="$(git rev-parse --verify "$RELEASE_SHA^:sdk/typescript/package.json" 2>/dev/null)"; then+ previous_version="$(+ git cat-file blob "$previous_manifest_oid" |+ node --input-type=module --eval '+ import { readFileSync } from "node:fs";+ const manifest = JSON.parse(readFileSync(0, "utf8"));+ if (typeof manifest.version !== "string") {+ throw new Error("The previous package version is missing.");+ }+ process.stdout.write(manifest.version);+ '+ )"+ if [[ "$version" == "$previous_version" ]]; then+ release_mode="$(+ printf '%s\n' "$published_versions" |+ node sdk/typescript/scripts/release-automation.mjs \+ release-mode "$version")"- if [[ "$version" == "$previous_version" ]]; then- release_mode="$(- printf '%s\n' "$published_versions" |- node sdk/typescript/scripts/release-automation.mjs \- release-mode "$version"+ if [[ "$release_mode" == "recover" ]]; then+ echo "Package version is unchanged and already published."+ echo "changed=false" >> "$GITHUB_OUTPUT"+ exit 0+ fi+ if tagged_sha="$(git rev-parse --verify "refs/tags/npm-v$version^{commit}" 2>/dev/null)" &&+ [[ "$tagged_sha" != "$RELEASE_SHA" ]] &&+ git merge-base --is-ancestor "$tagged_sha" "$RELEASE_SHA"; then+ tagged_version="$(+ git show "$tagged_sha:sdk/typescript/package.json" |+ node -p 'JSON.parse(require("node:fs").readFileSync(0, "utf8")).version')"- if [[ "$release_mode" == "recover" ]]; then- echo "Package version is unchanged and already published."+ if [[ "$tagged_version" == "$version" ]]; then+ echo "Package version is unchanged and already tagged at $tagged_sha."echo "changed=false" >> "$GITHUB_OUTPUT"exit 0fi- if tagged_sha="$(git rev-parse --verify "refs/tags/npm-v$version^{commit}" 2>/dev/null)" &&- [[ "$tagged_sha" != "$RELEASE_SHA" ]] &&- git merge-base --is-ancestor "$tagged_sha" "$RELEASE_SHA"; then- tagged_version="$(- git show "$tagged_sha:sdk/typescript/package.json" |- node -p 'JSON.parse(require("node:fs").readFileSync(0, "utf8")).version'- )"- if [[ "$tagged_version" == "$version" ]]; then- echo "Package version is unchanged and already tagged at $tagged_sha."- echo "changed=false" >> "$GITHUB_OUTPUT"- exit 0- fi- fi- else- node sdk/typescript/scripts/release-automation.mjs \- require-increase "$version" "$previous_version" >/dev/nullfi+ else+ node sdk/typescript/scripts/release-automation.mjs \+ require-increase "$version" "$previous_version" >/dev/nullfifidiff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.tsindex 983b49113..414d8c386 100644--- a/sdk/typescript/tests-ts/release-automation.test.ts+++ b/sdk/typescript/tests-ts/release-automation.test.ts@@ -1950,6 +1950,11 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}taggedVersion: "0.1.6",changed: true,},+ {+ scenario: "an unavailable blob for the previous package manifest",+ previousVersion: null,+ changed: false,+ },{scenario: "a successful fix after the version-increase commit failed CI",changed: true,@@ -2027,8 +2032,8 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}" fi"," ;;"," rev-parse)",- ' if [[ "$2" == "$RELEASE_SHA^" ]]; then',- " printf '%s\\n' \"$MOCK_PREVIOUS_SHA\"",+ ' if [[ "$2" == "--verify" && "$3" == "$RELEASE_SHA^:sdk/typescript/package.json" ]]; then',+ " echo previous-manifest",' elif [[ "$2" == "--verify" && "$3" == "refs/tags/npm-v$MOCK_RELEASE_VERSION^{commit}" ]]; then',' [[ -n "$MOCK_TAGGED_SHA" ]] || return 1'," printf '%s\\n' \"$MOCK_TAGGED_SHA\"",@@ -2042,9 +2047,14 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}' elif [[ "$2" == "$MOCK_TAGGED_SHA:sdk/typescript/package.json" ]]; then',' printf \'{"version":"%s"}\\n\' "$MOCK_TAGGED_VERSION"'," else",- ' printf \'{"version":"%s"}\\n\' "$MOCK_PREVIOUS_VERSION"',+ " return 64"," fi"," ;;",+ " cat-file)",+ ' [[ "$2 $3" == "blob previous-manifest" ]] || return 64',+ ' [[ -n "$MOCK_PREVIOUS_VERSION" ]] || { echo "unavailable manifest blob" >&2; return 1; }',+ ' printf \'{"version":"%s"}\\n\' "$MOCK_PREVIOUS_VERSION"',+ " ;;"," *) return 64 ;;"," esac","}",@@ -2067,8 +2077,7 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}GITHUB_OUTPUT: outputPath,GITHUB_REF: "refs/heads/main",GITHUB_SHA: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",- MOCK_PREVIOUS_SHA: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",- MOCK_PREVIOUS_VERSION: previousVersion,+ MOCK_PREVIOUS_VERSION: previousVersion ?? "",MOCK_PUBLISHED_VERSIONS: JSON.stringify(publishedVersions),MOCK_RELEASE_VERSION: currentVersion,MOCK_TAGGED_SHA: taggedSha,@@ -2079,6 +2088,12 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}{ cwd: fileURLToPath(new URL("../../../", import.meta.url)) },);+ if (previousVersion === null) {+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain("unavailable manifest blob");+ expect(existsSync(outputPath)).toBe(false);+ return;+ }expect(result.stderr).toBe("");expect(result.status).toBe(0);