|
3 | 3 | * via GraphQL API and
|
4 | 4 | * put them in a Google Sheet
|
5 | 5 | *
|
6 |
| -* NOTE: to change the number of results, manually change the values in "variables" on line 59 |
| 6 | +* NOTE: to change the number of results, |
| 7 | +* change the values in "variables" on line 72 or |
| 8 | +* change the query on line 55 |
| 9 | +* |
| 10 | +* DEPLOYMENT |
| 11 | +* 1. At https://docs.google.com/spreadsheets create a new Sheet |
| 12 | +* 2. In the Sheet, go to "Extensions" > "App Script" |
| 13 | +* 3. Create a new App Script using the contents of this file |
| 14 | +* 5. In Project Settings: Script Properties, click "Add script property" |
| 15 | +* 5.1. In https://app.boostsecurity.io/settings?tab=Application+Keys generate a key |
| 16 | +* 5.2. Set: Property = apiKey, Value = [key generate in previous step] |
| 17 | +* 6. Click "Deploy" > "New Deployment" and "Select type" > "Library". Click "Deploy" |
| 18 | +* 7. Click "Run" |
| 19 | +* To run automatically, create a trigger per https://developers.google.com/apps-script/guides/triggers/installable#managing_triggers_manually |
7 | 20 | */
|
8 | 21 |
|
9 | 22 | /**
|
10 | 23 | * Global Constants
|
11 | 24 | */
|
| 25 | +const SHEET_NAME = "BoostSecurity Finding Details"; |
| 26 | +const HEADERS = ["Finding ID", "Rule Name", "Scanner", "Suppression(s)", "URL"]; |
12 | 27 | const API_URL = "https://api.boostsecurity.io/findings-view/graphql";
|
13 | 28 | const API_KEY = PropertiesService.getScriptProperties().getProperty("apiKey");
|
14 | 29 | const AUTHORIZATION_HEADER = "ApiKey " + API_KEY;
|
15 |
| -const SHEET_NAME = "BoostSecurity Finding Details"; |
16 |
| -const HEADERS = ["Finding ID", "Rule Name", "Scanner", "Suppression(s)", "URL"]; |
17 | 30 |
|
18 | 31 | /**
|
19 | 32 | * Prepare the GraphQL query
|
@@ -63,6 +76,16 @@ function prepareQuery() {
|
63 | 76 | });
|
64 | 77 | }
|
65 | 78 |
|
| 79 | +/** |
| 80 | + * MAIN function to get all findings |
| 81 | + */ |
| 82 | +function getAllFindings() { |
| 83 | + let graphqlQuery = prepareQuery(); |
| 84 | + let response = fetchData(graphqlQuery); |
| 85 | + let findings = parseResponse(response); |
| 86 | + displayFindings(findings); |
| 87 | +} |
| 88 | + |
66 | 89 | /**
|
67 | 90 | * Fetch data from the API
|
68 | 91 | * @param {string} query - The GraphQL query to send to the API
|
@@ -137,13 +160,3 @@ function displayFindings(boostSecurityFindings) {
|
137 | 160 | console.error("No findings to display");
|
138 | 161 | }
|
139 | 162 | }
|
140 |
| - |
141 |
| -/** |
142 |
| - * Main function to get all findings |
143 |
| - */ |
144 |
| -function getAllFindings() { |
145 |
| - let graphqlQuery = prepareQuery(); |
146 |
| - let response = fetchData(graphqlQuery); |
147 |
| - let findings = parseResponse(response); |
148 |
| - displayFindings(findings); |
149 |
| -} |
|
0 commit comments