Skip to content

Commit 338d99b

Browse files
committed
fix: issues with runs
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
1 parent 01742f6 commit 338d99b

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

services/apps/security_best_practices_worker/example-config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ services:
1212
- Maturity Level 1
1313

1414
vars:
15-
owner: $REPO_OWNER
16-
repo: $REPO_NAME
17-
token: $GITHUB_TOKEN
15+
owner: "$REPO_OWNER"
16+
repo: "$REPO_NAME"
17+
token: "$GITHUB_TOKEN"

services/apps/security_best_practices_worker/src/activities/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ export async function getOSPSBaselineInsights(repoUrl: string, token: string): P
4444

4545
const combinedOutput = `${stdout}\n${stderr}`
4646

47+
if (combinedOutput.includes('401 Unauthorized')) {
48+
svc.log.warn('Detected 401 error in privateer output - token invalid or expired!')
49+
throw ApplicationFailure.create({
50+
message: 'GitHub token invalid or expired',
51+
type: 'Token403Error',
52+
})
53+
}
4754
if (combinedOutput.includes('403')) {
48-
svc.log.warn('Detected 403 error in privateer output!')
55+
svc.log.warn('Detected 403 error in privateer output - token rate-limited!')
4956
throw ApplicationFailure.create({
5057
message: 'GitHub token rate-limited',
5158
type: 'Token403Error',
@@ -54,10 +61,17 @@ export async function getOSPSBaselineInsights(repoUrl: string, token: string): P
5461
} catch (err) {
5562
svc.log.error(`Privateer run failed: ${err.message}`)
5663

57-
// check for 403 in captured output if available
64+
// check for auth errors in captured output if available
5865
const output = `${err.stdout || ''}\n${err.stderr || ''}`
66+
if (output.includes('401 Unauthorized')) {
67+
svc.log.warn('Detected 401 error in failed privateer output - token invalid or expired!')
68+
throw ApplicationFailure.create({
69+
message: 'GitHub token invalid or expired',
70+
type: 'Token403Error',
71+
})
72+
}
5973
if (output.includes('403')) {
60-
svc.log.warn('Detected 403 error in failed privateer output!')
74+
svc.log.warn('Detected 403 error in failed privateer output - token rate-limited!')
6175
throw ApplicationFailure.create({
6276
message: 'GitHub token rate-limited',
6377
type: 'Token403Error',

0 commit comments

Comments
 (0)