-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script to update q-expand from source XLSX #570
base: main
Are you sure you want to change the base?
Conversation
- Source data can be downloaded from GSA D2D with GSA login (instructions in q-expand-update.js)
["stub", "desc"], | ||
...outRows.map(({ stub, desc }) => [stub, desc]), | ||
]); | ||
fs.writeFileSync(outCsvPath, output); |
Check failure
Code scanning / CodeQL
Insecure temporary file High
the os temp dir
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 8 days ago
To fix the problem, we should use a well-tested library like tmp
to create temporary files securely. This library ensures that the file is inaccessible to other users and that the file does not already exist. We need to replace the hardcoded temporary file paths with paths generated by the tmp
library.
- Install the
tmp
library. - Replace the hardcoded temporary file paths in
src/scripts/q-expand-update.test.js
with paths generated by thetmp
library. - Ensure that the rest of the code uses these secure temporary file paths.
-
Copy modified line R3 -
Copy modified line R9 -
Copy modified line R25
@@ -2,2 +2,3 @@ | ||
const { parse } = require("csv-parse/sync"); // eslint-disable-line import/no-unresolved | ||
const tmp = require("tmp"); | ||
const Fs = require("fake-fs"); | ||
@@ -7,3 +8,3 @@ | ||
describe("q-expand-update", () => { | ||
const inXlsxPath = "/tmp/path/to/source.xlsx"; | ||
const inXlsxPath = tmp.fileSync({ postfix: ".xlsx" }).name; | ||
const xlsxData = [ | ||
@@ -23,3 +24,3 @@ | ||
it("converts xlsx into csv", () => { | ||
const outCsvPath = "/tmp/path/to/out.csv"; | ||
const outCsvPath = tmp.fileSync({ postfix: ".csv" }).name; | ||
|
-
Copy modified lines R29-R30
@@ -28,3 +28,4 @@ | ||
"pg": "^8.7.1", | ||
"plural": "^1.1.0" | ||
"plural": "^1.1.0", | ||
"tmp": "^0.2.3" | ||
}, |
Package | Version | Security advisories |
tmp (npm) | 0.2.3 | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This spec already uses fake-fs
which I think means this suggestion may not apply
I had an idea for streamlining the update process, I am happy to update the wiki page on this if folks think this is a viable approach!
I know the current approach allows for some custom renaming, for the time being, I went with direct conversion.
Checklist:
page has been updated if Charlie needs any new OAuth events or scopes
wiki page has been updated if new environment variables were introduced
or existing ones changed