| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 555b26e commit b674f1b
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ | |||
| 2 | 2 | // | |
| 3 | 3 | // SPDX-License-Identifier: Apache-2.0 | |
| 4 | 4 | ||
| 5 | - const axios = require("axios"); | ||
| 6 | 5 | const { handle } = require("./hook/hook"); | |
| 7 | 6 | const k8s = require("@kubernetes/client-node"); | |
| 8 | 7 | ||
@@ -16,7 +15,37 @@ kc.loadFromCluster(); | |||
| 16 | 15 | const k8sApi = kc.makeApiClient(k8s.CustomObjectsApi); | |
| 17 | 16 | ||
| 18 | 17 | function downloadFile(url) { | |
| 19 | - return axios.get(url); | ||
| 18 | + return fetch(url) | ||
| 19 | + .then(response => { | ||
| 20 | + if (!response.ok) { | ||
| 21 | + return response.text().then(body => { | ||
| 22 | + throw new Error(`Failed to download file with Response Code: ${response.status} - ${body}`); | ||
| 23 | + }); | ||
| 24 | + } | ||
| 25 | + return response; | ||
| 26 | + }); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + function uploadFile(url, fileContents) { | ||
| 30 | + return fetch(url, { | ||
| 31 | + method: 'PUT', | ||
| 32 | + headers: { 'Content-Type': '' }, | ||
| 33 | + body: fileContents | ||
| 34 | + }) | ||
| 35 | + .then(response => { | ||
| 36 | + if (!response.ok) { | ||
| 37 | + return response.text().then(body => { | ||
| 38 | + console.error(`File Upload Failed with Response Code: ${response.status}`); | ||
| 39 | + console.error(`Error Response Body: ${body}`); | ||
| 40 | + process.exit(1); | ||
| 41 | + }); | ||
| 42 | + } | ||
| 43 | + // Successful response | ||
| 44 | + }) | ||
| 45 | + .catch(error => { | ||
| 46 | + console.error(error.message); | ||
| 47 | + process.exit(1); | ||
| 48 | + }); | ||
| 20 | 49 | } | |
| 21 | 50 | ||
| 22 | 51 | function getRawResults() { | |
@@ -35,32 +64,6 @@ function getFindings() { | |||
| 35 | 64 | }); | |
| 36 | 65 | } | |
| 37 | 66 | ||
| 38 | - function uploadFile(url, fileContents) { | ||
| 39 | - return axios | ||
| 40 | - .put(url, fileContents, { | ||
| 41 | - headers: { "content-type": "" }, | ||
| 42 | - }) | ||
| 43 | - .catch(function(error) { | ||
| 44 | - if (error.response) { | ||
| 45 | - // The request was made and the server responded with a status code | ||
| 46 | - // that falls out of the range of 2xx | ||
| 47 | - console.error( | ||
| 48 | - `File Upload Failed with Response Code: ${error.response.status}` | ||
| 49 | - ); | ||
| 50 | - console.error(`Error Response Body: ${error.response.data}`); | ||
| 51 | - } else if (error.request) { | ||
| 52 | - console.error( | ||
| 53 | - "No response received from FileStorage when uploading finding" | ||
| 54 | - ); | ||
| 55 | - console.error(error); | ||
| 56 | - } else { | ||
| 57 | - // Something happened in setting up the request that triggered an Error | ||
| 58 | - console.log("Error", error.message); | ||
| 59 | - } | ||
| 60 | - process.exit(1); | ||
| 61 | - }); | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | 67 | function updateRawResults(fileContents) { | |
| 65 | 68 | const rawResultUploadUrl = process.argv[4]; | |
| 66 | 69 | if (rawResultUploadUrl === undefined) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,6 @@ | |||
| 11 | 11 | "license": "Apache-2.0", | |
| 12 | 12 | "dependencies": { | |
| 13 | 13 | "@kubernetes/client-node": "^0.19.0", | |
| 14 | - "axios": "^1.6.0", | ||
| 15 | 14 | "ws": "^8.13.0" | |
| 16 | 15 | } | |
| 17 | 16 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,6 @@ | |||
| 11 | 11 | "ajv": "^8.12.0", | |
| 12 | 12 | "ajv-draft-04": "^1.0.0", | |
| 13 | 13 | "ajv-formats": "^2.1.0", | |
| 14 | - "axios": "^1.6.0", | ||
| 15 | 14 | "jsonpointer": "^5.0.1", | |
| 16 | 15 | "ws": "^8.13.0" | |
| 17 | 16 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments