Skip to content

Commit d71d865

Browse files
warengonzagaCopilot
andcommitted
⚙️ setup (ci): fix security, guards, and validation issues
- add if-guard to package/container jobs (main push only) - narrow ci.yml top-level permissions to contents: read - add per-job permissions for package and container jobs - remove unused packages/security-events write from release.yml - fix commit-lint push range to validate all commits (before..after) - quote SHA interpolations in commit-lint PR log command - remove duplicate bun run build step from package.yml - add --bail flag to pre-commit bun test hook - add msgFile undefined guard in validate-commit-msg.mjs - make variation selector optional for trash and gear emojis - strengthen readCache to validate latest and runtime field types Co-authored-by: Copilot <[email protected]>
1 parent 57d3d0f commit d71d865

7 files changed

Lines changed: 24 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ on:
99

1010
permissions:
1111
contents: read
12-
packages: write
13-
security-events: write
14-
pull-requests: write
1512

1613
jobs:
1714
build:
@@ -56,10 +53,19 @@ jobs:
5653

5754
package:
5855
needs: test
56+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
57+
permissions:
58+
packages: write
59+
pull-requests: write
5960
uses: ./.github/workflows/package.yml
6061
secrets: inherit
6162

6263
container:
6364
needs: test
65+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
66+
permissions:
67+
packages: write
68+
security-events: write
69+
pull-requests: write
6470
uses: ./.github/workflows/container.yml
6571
secrets: inherit

.github/workflows/commit-lint.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ jobs:
2525
PATTERN='^(📦|🔧|🗑️|🔒|⚙️|☕|🧪|📖|🚀) (new|update|remove|security|setup|chore|test|docs|release)( \([a-z0-9][a-z0-9-]*\))?: .{1,72}$'
2626
2727
if [ "${{ github.event_name }}" = "pull_request" ]; then
28-
COMMITS=$(git log --format="%s" ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
28+
COMMITS=$(git log --format="%s" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}")
2929
else
30-
COMMITS=$(git log --format="%s" -1)
30+
GITHUB_EVENT_BEFORE="${{ github.event.before }}"
31+
GITHUB_EVENT_AFTER="${{ github.event.after }}"
32+
if [ "$GITHUB_EVENT_BEFORE" = "0000000000000000000000000000000000000000" ]; then
33+
COMMITS=$(git log --format="%s" "$GITHUB_EVENT_AFTER" -1)
34+
else
35+
COMMITS=$(git log --format="%s" "${GITHUB_EVENT_BEFORE}..${GITHUB_EVENT_AFTER}")
36+
fi
3137
fi
3238
3339
FAILED=0

.github/workflows/package.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ jobs:
3333
- name: Install dependencies
3434
run: bun install --frozen-lockfile
3535

36-
- name: Build all packages
37-
run: bun run build
38-
3936
- name: Build & Publish Packages
4037
uses: wgtechlabs/[email protected]
4138
with:

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88

99
permissions:
1010
contents: write
11-
packages: write
12-
security-events: write
1311
pull-requests: write
1412

1513
jobs:

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun test
1+
bun test --bail

.husky/validate-commit-msg.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { readFileSync } from "fs";
22

33
const msgFile = process.argv[2];
4+
if (!msgFile) {
5+
console.error("Error: No commit message file path provided.");
6+
process.exit(1);
7+
}
48
const raw = readFileSync(msgFile, "utf8");
59
const firstLine = raw.replace(/\r/g, "").split("\n")[0].trim();
610

@@ -10,7 +14,7 @@ if (/^Merge /.test(firstLine)) process.exit(0);
1014
// Clean Commit convention pattern
1115
// Format: <emoji> <type>[(<scope>)]: <description>
1216
const pattern =
13-
/^(📦|🔧|🗑|🔒|||🧪|📖|🚀) (new|update|remove|security|setup|chore|test|docs|release)( \([a-z0-9][a-z0-9-]*\))?: .{1,72}$/u;
17+
/^(📦|🔧|🗑\uFE0F?|🔒|\uFE0F?||🧪|📖|🚀) (new|update|remove|security|setup|chore|test|docs|release)( \([a-z0-9][a-z0-9-]*\))?: .{1,72}$/u;
1418

1519
if (!pattern.test(firstLine)) {
1620
console.error("");

packages/core/src/update-checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function readCache(dataDir: string): UpdateInfo | null {
118118
try {
119119
const raw = readFileSync(getCachePath(dataDir), 'utf-8');
120120
const cached = JSON.parse(raw) as UpdateInfo;
121-
if (cached && typeof cached.checkedAt === 'number') return cached;
121+
if (cached && typeof cached.checkedAt === 'number' && typeof cached.latest === 'string' && typeof cached.runtime === 'string') return cached;
122122
} catch {
123123
// Missing or corrupt — will re-check
124124
}

0 commit comments

Comments
 (0)