Skip to content

Commit 46ce7a0

Browse files
committed
add back the generateUILink
1 parent 7cb9759 commit 46ce7a0

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/util.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { error, getInput, info, isDebug } from '@actions/core'
2+
import { context } from '@actions/github'
23
import { spawn } from 'child_process'
34
import { readFileSync, mkdirSync } from 'fs'
45
import * as path from 'path'
@@ -65,6 +66,31 @@ export function getOrDefault(name: string, defaultValue: string) {
6566
return defaultValue
6667
}
6768

69+
export function generateUILink() {
70+
const eventPath = process.env.GITHUB_EVENT_PATH!
71+
const eventData = JSON.parse(readFileSync(eventPath, 'utf8'))
72+
const defaultBranch = eventData.repository?.default_branch
73+
74+
const targetBranch = getRequiredEnvVariable('GITHUB_BASE_REF')
75+
76+
if (targetBranch !== defaultBranch) return ''
77+
78+
let lwAccountName = process.env.LW_ACCOUNT_NAME
79+
lwAccountName = lwAccountName?.replace(/\.lacework\.net$/, '')
80+
81+
let url =
82+
`https://${lwAccountName}.lacework.net` +
83+
`/ui/investigation/codesec/applications/repositories/` +
84+
`github.com%2F${context.repo.owner}%2F${context.repo.repo}` +
85+
`/${defaultBranch}`
86+
87+
if (process.env.LW_SUBACCOUNT_NAME) {
88+
url += '?accountName=' + process.env.LW_SUBACCOUNT_NAME
89+
}
90+
91+
return url
92+
}
93+
6894
// codesecRun - Docker-based scanner using codesec:latest image
6995
// Follows the pattern from test-unified-scanner.sh for CI runner compatibility
7096
//

0 commit comments

Comments
 (0)