|
1 | 1 | import { error, getInput, info, isDebug } from '@actions/core' |
| 2 | +import { context } from '@actions/github' |
2 | 3 | import { spawn } from 'child_process' |
3 | 4 | import { readFileSync, mkdirSync } from 'fs' |
4 | 5 | import * as path from 'path' |
@@ -65,6 +66,31 @@ export function getOrDefault(name: string, defaultValue: string) { |
65 | 66 | return defaultValue |
66 | 67 | } |
67 | 68 |
|
| 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 | + |
68 | 94 | // codesecRun - Docker-based scanner using codesec:latest image |
69 | 95 | // Follows the pattern from test-unified-scanner.sh for CI runner compatibility |
70 | 96 | // |
|
0 commit comments