Skip to content

Commit c31aae9

Browse files
authored
Merge pull request #102 from anoncam/fix/security-vulnerabilities
fix(security): resolve GitHub code scanning vulnerabilities
2 parents a882d82 + d87a138 commit c31aae9

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

‎.github/workflows/release-with-sbom.yml‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ jobs:
129129
130130
- name: Check for existing GitHub release
131131
id: check-release
132+
env:
133+
VERSION_INPUT: ${{ steps.get-version.outputs.version }}
132134
run: |
133-
VERSION="${{ steps.get-version.outputs.version }}"
135+
VERSION="${VERSION_INPUT}"
134136
echo "Checking if GitHub release v$VERSION already exists..."
135137
136138
# Set GH_TOKEN for gh CLI
@@ -425,15 +427,19 @@ jobs:
425427

426428
- name: Set version for release
427429
id: version
430+
env:
431+
VERSION_INPUT: ${{ needs.check-version.outputs.version }}
428432
run: |
429-
echo "version=${{ needs.check-version.outputs.version }}" >> $GITHUB_OUTPUT
430-
echo "Using version: ${{ needs.check-version.outputs.version }}"
433+
echo "version=${VERSION_INPUT}" >> $GITHUB_OUTPUT
434+
echo "Using version: ${VERSION_INPUT}"
431435
432436
- name: Debug release information
437+
env:
438+
VERSION_INPUT: ${{ needs.check-version.outputs.version }}
433439
run: |
434440
echo "========== RELEASE DEBUG INFO =========="
435-
echo "Release version: v${{ needs.check-version.outputs.version }}"
436-
echo "Creating tag: v${{ needs.check-version.outputs.version }}"
441+
echo "Release version: v${VERSION_INPUT}"
442+
echo "Creating tag: v${VERSION_INPUT}"
437443
echo "Checking if artifacts are available..."
438444
echo "========================================"
439445

‎cli/pgpUtils.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ async function importPgpKey(pgpKeyString: string, identifier: string | null = nu
292292

293293
// Extract name (everything before the email)
294294
let nameStr = userIdStr;
295-
// Remove email in angle brackets
295+
// Remove email in angle brackets (use global flag to remove all occurrences)
296296
if (nameStr.includes('<') && nameStr.includes('>')) {
297-
nameStr = nameStr.replace(/<[^>]*>/, '');
297+
nameStr = nameStr.replace(/<[^>]*>/g, '');
298298
}
299299
// Remove any remaining email address format
300300
nameStr = nameStr.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/, '');
@@ -349,9 +349,10 @@ async function importPgpKey(pgpKeyString: string, identifier: string | null = nu
349349
}
350350

351351
// Extract name (everything before the comment and email)
352+
// Use global flag to remove all occurrences for complete sanitization
352353
let nameStr = userIdStr;
353-
if (commentMatch) nameStr = nameStr.replace(/\s*\([^)]+\)\s*/, ' ');
354-
if (emailMatch) nameStr = nameStr.replace(/\s*<[^>]+>\s*/, '');
354+
if (commentMatch) nameStr = nameStr.replace(/\s*\([^)]+\)\s*/g, ' ');
355+
if (emailMatch) nameStr = nameStr.replace(/\s*<[^>]+>\s*/g, '');
355356
name = nameStr.trim() || name;
356357
}
357358
} catch (error: any) {

‎cli/unifiedKeyManager.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,12 @@ export async function searchKeys(query: string, options: SearchOptions = {}): Pr
284284
}
285285

286286
// Extract name from UID (if present)
287+
// Use global flag to remove all occurrences for complete sanitization
287288
let name = uidString;
288289
if (emailMatch) {
289-
name = uidString.replace(/<[^>]+>/, '').trim();
290+
name = uidString.replace(/<[^>]+>/g, '').trim();
290291
}
291-
292+
292293
// Check if it matches the query
293294
if (
294295
fieldMatches(key.id) ||
@@ -428,11 +429,12 @@ export async function getKeyById(id: string, options: SearchOptions = {}): Promi
428429
}
429430

430431
// Extract name from UID (if present)
432+
// Use global flag to remove all occurrences for complete sanitization
431433
let name = uidString;
432434
if (emailMatch) {
433-
name = uidString.replace(/<[^>]+>/, '').trim();
435+
name = uidString.replace(/<[^>]+>/g, '').trim();
434436
}
435-
437+
436438
return {
437439
id: gpgKey.id,
438440
name: name,

0 commit comments

Comments
 (0)