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

LZ to DMZ Sync #709

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open

LZ to DMZ Sync #709

wants to merge 16 commits into from

Conversation

jayjaybunce
Copy link
Collaborator

@jayjaybunce jayjaybunce commented Oct 30, 2024

🗣 Description

  • Changed VS Sync scan to post org data to endpoint in chunks of 1000 orgs
  • Added endpoint to ingest data from VS Sync scan
  • Added a local copy of the MDL (the one in DMZ)
  • Added syndnewmdl script to stand up the tables for the local MDL
  • Implemented CSV parser middleware to allow CSV data ingests on the new endpoint

💭 Motivation and context

Resolves CRASM-714 + CRASM-785

🧪 Testing

Testing Steps

Prepare your local environment

  1. Stop all containers
  2. Add the below to your .env
MDL_USERNAME=mdl_local
MDL_PASSWORD=mini_data_lake
MDL_HOST=xfd-db-1
MDL_DATABASE=mini_data_lake_local
DMZ_API_KEY=d196030065c564bed15f8a8fc3ca90c7
OLD_MDL_USERNAME=mdl 
OLD_MDL_PASSWORD=password 
OLD_MDL_NAME=crossfeed_mini_datalake 
  1. Remove the contents of /postgres-data => This will reset your local app database
  2. /backend => npm run mdl-datagen
  • See below if you have an M1 or M2 chip
  1. Start all containers (ensure they are rebuilt)

  2. /backend => npm run syncdb -- -d populate

  3. /backend => npm run syncnewmdl

  4. /backend => npm run syncmdl

  5. docker cp /path/to/your/ mdl_backup_data.sql xfd-db-1:/tmp/mdl_backup_data.sql

  6. Connect to the database docker => Run: docker exec -it xfd-db-1 bash
    10b. psql -U mdl -d crossfeed_mini_datalake -f tmp/mdl_backup_data.sql

  7. Login to the application

  8. Open developer tools and go to network => Copy the Auth header from any request

  9. Add this to .env

DMZ_API_KEY=<yourtoken>
  1. Build worker => /backend => npm run build-worker
  2. Restart all containers
  • See below if you have an M1 or M2 MacBook
  1. Go to Admin-Tools
  2. Create a new scan => vulnScanningSync
  3. Click the play button next to the scan to manually trigger it
  4. Connect to the local MDL with the below connection details
host: 127.0.0.1
username: mdl_local
password:: mini_data_lake
database: mini_data_lake_local
  1. Confirm there are now records in the organization, cidr and cidr_organizations tables

Build Worker for M1/M2 Apple chips

A. Add the following below line 4 in /backend/Dockerfile.worker

RUN apk add --no-cache python3 py3-pip make g++

# Ensure python command points to python3
RUN ln -sf python3 /usr/bin/python```

B. /backend => docker build -t crossfeed-worker -f Dockerfile.worker .

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All future TODOs are captured in issues, which are referenced
    in code comments.
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All relevant repo and/or project documentation has been updated
    to reflect the changes in this PR.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.

✅ Pre-merge checklist

  • Revert dependencies to default branches.
  • Finalize version.

✅ Post-merge checklist

  • Create a release.

Comment on lines +18 to +19
{} as any,
() => null

Check warning

Code scanning / CodeQL

Superfluous trailing arguments Warning

Superfluous arguments passed to
function handler
.
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