Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zachmargolis
Copy link
Contributor

  • Source data can be downloaded from GSA D2D with GSA login (instructions in q-expand-update.js)

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:

  • Code has been formatted with prettier
  • The OAuth wiki
    page has been updated if Charlie needs any new OAuth events or scopes
  • The Environment Variables
    wiki page has been updated if new environment variables were introduced
    or existing ones changed
  • The dev wiki has been updated, e.g.:
    • local development processes have changed
    • major development workflows have changed
    • internal utilities or APIs have changed
    • testing or deployment processes have changed
  • If appropriate, the NIST 800-218 documentation has been updated

- Source data can be downloaded from GSA D2D with GSA login
  (instructions in q-expand-update.js)
@zachmargolis zachmargolis requested a review from a team as a code owner January 31, 2025 19:20
["stub", "desc"],
...outRows.map(({ stub, desc }) => [stub, desc]),
]);
fs.writeFileSync(outCsvPath, output);

Check failure

Code scanning / CodeQL

Insecure temporary file High

Insecure creation of file in
the os temp dir
.

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.

  1. Install the tmp library.
  2. Replace the hardcoded temporary file paths in src/scripts/q-expand-update.test.js with paths generated by the tmp library.
  3. Ensure that the rest of the code uses these secure temporary file paths.
Suggested changeset 2
src/scripts/q-expand-update.test.js
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/scripts/q-expand-update.test.js b/src/scripts/q-expand-update.test.js
--- a/src/scripts/q-expand-update.test.js
+++ b/src/scripts/q-expand-update.test.js
@@ -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;
 
EOF
@@ -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;

package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -28,3 +28,4 @@
     "pg": "^8.7.1",
-    "plural": "^1.1.0"
+    "plural": "^1.1.0",
+    "tmp": "^0.2.3"
   },
EOF
@@ -28,3 +28,4 @@
"pg": "^8.7.1",
"plural": "^1.1.0"
"plural": "^1.1.0",
"tmp": "^0.2.3"
},
This fix introduces these dependencies
Package Version Security advisories
tmp (npm) 0.2.3 None
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant