Log in through the Veracode Okta Login and save cookies and CSRF token to json.
- Make sure you have NodeJS installed (This was tested on v12 and v16).
- Set up the
apiCredsUrlfor the Okta environment you want to log into via thesettings.jsonfile.- This should point to the monolith API Credentials page where you want to grab the CSRF token from.
- Navigate to the root directory of the project (
/veracode_login). - Install the dependencies via
npm i. - Run the project with
npm run start -- exampleUsername examplePasswordto get the cookies and monolith CSRF token for the user (replacing the exampleUsername and examplePassword).- You could instead fill out the
.envfile based on the.env.example, or pass environment variables VERACODE_USERNAME and VERACODE_PASSWORD and just runnpm run start.
- You could instead fill out the
- Utilize the
output.jsonfile which follows the format in the example shown.
{
"cookies": [
{
"name": "XSRF-TOKEN",
"value": "9+B11MAH11PyNpHf11deeeezabcasiBzAimaginewagonscqBubTauY7123+12==",
"domain": ".analysiscenter.veracode.com",
"path": "/",
"expires": -1,
"size": 122,
"httpOnly": false,
"secure": true,
"session": true,
"sameParty": false,
"sourceScheme": "Secure",
"sourcePort": 443
},
{
"name": "vsid",
"value": "86753098-6753-0986-7530-986753098675",
"domain": ".analysiscenter.veracode.com",
"path": "/",
"expires": -1,
"size": 40,
"httpOnly": true,
"secure": true,
"session": true,
"sameParty": false,
"sourceScheme": "Secure",
"sourcePort": 443
}
],
"csrfToken": "d1b8d127b8d3buqahjhwb81b783y7b12by83"
}➜ veracode_login git:(main) ✗ npm run start -- exampleUsername examplePassword
> veracode_login@1.0.0 start /Users/literallyjustroy/dev/auto/veracode_login
> tsc && node dist/auth.js "exampleUsername" "examplePassword"
[2022-09-07T17:52:53.720] [DEBUG] default - Attempting sign in as exampleUsername to http://web.analysiscenter.veracode.com
[2022-09-07T17:52:57.413] [INFO] default - Entering username...
[2022-09-07T17:52:57.480] [INFO] default - Entering password...
[2022-09-07T17:52:57.527] [INFO] default - Submitting...
[2022-09-07T17:52:57.586] [INFO] default - Waiting for navigation and cookie...
[2022-09-07T17:53:02.965] [INFO] default - Desired cookie located! (vsid)
[2022-09-07T17:53:02.965] [INFO] default - Navigating to API Credentials page to grab CSRF token
[2022-09-07T17:53:02.966] [INFO] default - Saving cookies and csrf token...
[2022-09-07T17:53:02.967] [DEBUG] default - Cookies and CSRF token saved to /Users/literallyjustroy/dev/auto/veracode_login/output.jsonYou can read cookies from this file via NodeJS Puppeteer like so:
const cookiesString = fs.readFileSync('./cookies.json', 'utf8');
const cookies: puppeteer.Protocol.Network.Cookie[] = JSON.parse(cookiesString).cookies;