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

Integration - Python Backend #751

Merged
merged 378 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
378 commits
Select commit Hold shift + click to select a range
cdf9cfb
Saved Search tests skeleton
chrtorres Oct 29, 2024
b7756b2
Add stats endpoints,settings and management commands
aloftus23 Oct 30, 2024
aa217dc
Code cleanup
chrtorres Oct 30, 2024
7195c90
Add register endpoints and post User with tests in test_user.py
aloftus23 Oct 30, 2024
764e04f
Merge pull request #710 from cisagov/CT-saved-search-tests
aloftus23 Oct 30, 2024
6e6d527
Update python user endpoints.
Matthew-Grayson Oct 30, 2024
12ec1aa
Merge origin MG-python-serverless into remote MG-python-serverless.
Matthew-Grayson Oct 30, 2024
0e43828
Merge origin MG-python-serverless into remote MG-python-serverless.
Matthew-Grayson Oct 30, 2024
06771bc
Fix lint issues in email.py.
Matthew-Grayson Oct 31, 2024
e525a9f
Merge branch 'AL-python-serverless' of github.com:cisagov/XFD into MG…
Matthew-Grayson Nov 4, 2024
d17790b
Add status endpoints
aloftus23 Nov 4, 2024
0bf960c
Merge branch 'AL-python-serverless' into cd_elasticache_updated
cduhn17 Nov 4, 2024
d569f5a
Update env variables at and integrate at settings.py
aloftus23 Nov 5, 2024
7535e27
Merge branch 'cd_elasticache_updated' of github.com:cisagov/XFD into …
aloftus23 Nov 5, 2024
9cca210
Remove Bearer requirement from Authorization token and update docstrings
nickviola Nov 5, 2024
c9db522
Update auth to use X-API-KEY or Authorization header and not require …
nickviola Nov 5, 2024
f0fe7b8
Update variable names for attribute errors
aloftus23 Nov 7, 2024
0fe8b53
Remove ReadySetCyber from Python Backend
Matthew-Grayson Nov 8, 2024
b20fd0c
Update python auth function comments and spacing
nickviola Nov 12, 2024
1eb4584
Update python auth function comments and spacing
nickviola Nov 12, 2024
5d0e558
First commit to integration
aloftus23 Nov 13, 2024
37bcedf
fix backend.yml
aloftus23 Nov 13, 2024
29434c3
Run linter and fix backend.yml
aloftus23 Nov 13, 2024
8a42c31
Update auth header functionality to use either x-api-key or authoriza…
nickviola Nov 13, 2024
b501721
Fix the pytest configuration and add to makefile
aloftus23 Nov 13, 2024
060c3ff
make sure docker is running for the pytests
aloftus23 Nov 13, 2024
5aed36f
Delete the extra test_python and run pytest in "test"
aloftus23 Nov 13, 2024
be8b5e2
Fix backend.yml
aloftus23 Nov 13, 2024
c07443f
Update infrastructure pipeline to use stag-cd instead of stage
aloftus23 Nov 13, 2024
bd20a76
Add test cases for domains and fixed issues in domains and vulnerabil…
JCantu248 Nov 13, 2024
976db4a
Add serverless-python-requirements to package.json
aloftus23 Nov 13, 2024
a572a2d
Merge pull request #719 from cisagov/718-remove-readysetcyber-python-…
Matthew-Grayson Nov 14, 2024
a9a0d02
Merge pull request #714 from cisagov/NV-python-auth-updates
nickviola Nov 14, 2024
b503562
Remove unneeded django components b/c only using ORM
aloftus23 Nov 14, 2024
9e09de4
WIP.
JCantu248 Nov 14, 2024
68335fe
WIP. Adding vulnerability test file and update related api files prio…
JCantu248 Nov 14, 2024
836287e
Remove build_worker dependency
aloftus23 Nov 14, 2024
d7cb6cf
Merge branch 'AL-python-serverless' of github.com:cisagov/XFD into jd…
JCantu248 Nov 14, 2024
924ff35
Add python3.11 to backend deployment conatiner
aloftus23 Nov 14, 2024
cbeb3da
Remove resource policy variable
aloftus23 Nov 14, 2024
0ef9932
Remove resource policy from frontend variables
aloftus23 Nov 14, 2024
d5d5420
Fix api-keys endpoint by updating api method response and schema model
nickviola Nov 14, 2024
f425b0e
Remove api-keys model commented code
nickviola Nov 14, 2024
a5403ae
Add missing variables to integration.tfvars
aloftus23 Nov 15, 2024
7cc8fa3
Change default values in aws_region variablies
aloftus23 Nov 15, 2024
a82a206
Add region to terraform plan
aloftus23 Nov 15, 2024
0dfc4d8
Merge pull request #725 from cisagov/NV-python-api-key-endpoint-fixes
nickviola Nov 15, 2024
c09850a
Vulnerabilities test cases work, refactor for improved clarity on fil…
JCantu248 Nov 15, 2024
32400cd
Add permissions check back in now that authentication works.
JCantu248 Nov 15, 2024
d1a5fd2
Merge branch 'AL-python-serverless' into integration
aloftus23 Nov 15, 2024
de3157b
Updated Saved Search unit tests, test_create_saved_search_by_user in …
chrtorres Nov 15, 2024
6c6c129
Updated Saved Search unit tests, test_list_saved_searches_by_global_v…
chrtorres Nov 15, 2024
f6f65bf
Add region to all the terraform jobs
aloftus23 Nov 15, 2024
c4b30d4
Add test case for get vulnerability when no record is found, resultin…
JCantu248 Nov 15, 2024
3f90c2a
Updated Saved Search unit tests:
chrtorres Nov 18, 2024
bb03fd9
Fix s3 ACL definitions by adding ownership, create variables for elas…
aloftus23 Nov 18, 2024
e122508
Fixed vulnerability_update test cases, fix vulnerability_update method.
JCantu248 Nov 18, 2024
b5b6bf6
Merge branch 'AL-python-serverless' of github.com:cisagov/XFD into jd…
JCantu248 Nov 18, 2024
082a6ed
Add correct Availiability Zone to motomo db and fix worker policy typo
aloftus23 Nov 18, 2024
0bd47d9
Revert added quotes in worker policy
aloftus23 Nov 18, 2024
9235e9d
Add depends_on to aws_instance
aloftus23 Nov 18, 2024
e0ae921
Add test case for GET domain not found ends in a 404.
JCantu248 Nov 19, 2024
87d9391
Merge pull request #727 from cisagov/jd-domain-vuln-test-cases
JCantu248 Nov 19, 2024
c03de90
remove npm dependencies
aloftus23 Nov 19, 2024
7794f92
Add test fixtures to create users and vulnerabilities to test_domain,…
JCantu248 Nov 19, 2024
6302a57
Update package-lock
aloftus23 Nov 19, 2024
50e3cf3
Remove test_worker dependency
aloftus23 Nov 19, 2024
bc3768f
Updated Saved Search unit tests:
chrtorres Nov 19, 2024
a539e51
Merge remote-tracking branch 'origin/AL-python-serverless' into CT-un…
chrtorres Nov 19, 2024
101e417
Merge branch 'AL-python-serverless' into integration
aloftus23 Nov 19, 2024
2136652
Update views.py to have all functions replaced into api_methods direc…
aloftus23 Nov 19, 2024
f4f429a
Merge branch 'AL-python-serverless' into cd_elasticache_updated
cduhn17 Nov 19, 2024
a7b6643
fix cognito URL
aloftus23 Nov 19, 2024
4e00d01
Update cognito variables in backend
aloftus23 Nov 19, 2024
04e5d98
Merge branch 'AL-python-serverless' of github.com:cisagov/XFD into MG…
Matthew-Grayson Nov 19, 2024
c49dd9a
Fix backend handler path
aloftus23 Nov 20, 2024
23c339f
Add django_settings_module env variable
aloftus23 Nov 20, 2024
9b4c1bd
Add python requirements custom settings to serverless
aloftus23 Nov 20, 2024
46fe507
Update xfd_api/auth.py for lint issues
aloftus23 Nov 20, 2024
06695a6
Add logging middleware
aloftus23 Nov 20, 2024
ca74cc2
Update xfd_api/views.py for lint issues
aloftus23 Nov 20, 2024
cf11a51
Update logger middleware to include the necessary fields
aloftus23 Nov 20, 2024
0d47695
Update xfd_api/views to remove Assessement function
aloftus23 Nov 20, 2024
421ddef
Fix fetch of aws_context
aloftus23 Nov 20, 2024
61f9fd8
Merge pull request #707 from cisagov/cd_elasticache_updated
cduhn17 Nov 20, 2024
3bd0633
Updated the remaining unit tests:
chrtorres Nov 20, 2024
e38ceb0
Add updated content security policy and security headers
aloftus23 Nov 20, 2024
544adc5
Fix frontend CSP to use env variables
aloftus23 Nov 20, 2024
8b75154
Run syncdb
aloftus23 Nov 20, 2024
ef94754
Fix comment in backend.yml
aloftus23 Nov 20, 2024
7c093e9
fix syncdb lambda
aloftus23 Nov 20, 2024
d635a26
Set syncdb pythonpath correctly
aloftus23 Nov 20, 2024
5d52d56
Adjust PythonPatth
aloftus23 Nov 20, 2024
4056867
Run syncdb programmatically instead of subprocess
aloftus23 Nov 20, 2024
f46b571
Refine the migration steps
aloftus23 Nov 20, 2024
b101bb1
Move django.setup before import
aloftus23 Nov 20, 2024
63c01d6
Added fixtures to eleminate repetitive code; performed code cleanup a…
chrtorres Nov 20, 2024
2c51f39
Removed logging statements and commented out code
chrtorres Nov 20, 2024
757ed4d
Code cleanup; Placed UUID validation outside of try blocks for saved_…
chrtorres Nov 20, 2024
7f1790f
Move syndb populate and dangerouslyforce to syncdb_helpers
aloftus23 Nov 20, 2024
bfe727b
Create bastion lambda function
aloftus23 Nov 20, 2024
d6ea71e
Refactor User Endpoints to Follow Best Practice
Matthew-Grayson Nov 20, 2024
d79c45c
Update syncdb to apply migrations dynamically
aloftus23 Nov 20, 2024
5295728
Initialize django before import in syncdb
aloftus23 Nov 20, 2024
143f8d1
Merge branch 'AL-python-serverless' of github.com:cisagov/XFD into MG…
Matthew-Grayson Nov 20, 2024
6711338
Clean up logging in syncdb and make sure to reset migration state
aloftus23 Nov 20, 2024
f38c2ac
Fix dynamic migrations
aloftus23 Nov 20, 2024
c1545e1
Revert Deleted User Endpoints
Matthew-Grayson Nov 20, 2024
e9de9ba
Merge pull request #729 from cisagov/CT-unit-testing-saved-searches
chrtorres Nov 20, 2024
3e821a7
Run syncdb using schemaEditor instead of migrations
aloftus23 Nov 20, 2024
3ed79be
Remove db_table from many_to_many relationships
aloftus23 Nov 20, 2024
c030fbc
Revert "Remove db_table from many_to_many relationships"
aloftus23 Nov 20, 2024
f7d6806
Add handling for many to manys in synchronize
aloftus23 Nov 20, 2024
a79d7fc
Remove mdl function for now - will be replaced
aloftus23 Nov 20, 2024
2287c63
Force redeploy on integration backend
aloftus23 Nov 21, 2024
7454c16
Revert force redeploy
aloftus23 Nov 21, 2024
5421d46
Add environment variables
aloftus23 Nov 21, 2024
a54d1d2
Add frontend to allowed hosts
aloftus23 Nov 21, 2024
01f86fe
Remove the deploy backend removal
aloftus23 Nov 21, 2024
554f4d8
Revert "Remove the deploy backend removal"
aloftus23 Nov 21, 2024
b5368e9
Revert "Revert "Remove the deploy backend removal""
aloftus23 Nov 21, 2024
c528e5c
Fix logger and bastion
aloftus23 Nov 21, 2024
202a181
Fix logger timestamp
aloftus23 Nov 21, 2024
11f685d
Fix syncdb naming and dangerouslyforcs and make new users/me to have …
aloftus23 Nov 21, 2024
1a127da
Add search/organizations endpoint
aloftus23 Nov 21, 2024
66bc973
Merge pull request #713 from cisagov/MG-python-serverless
Matthew-Grayson Nov 21, 2024
cf3058d
Merge branch 'AL-python-serverless' into integration
aloftus23 Nov 21, 2024
aa27ad6
Merge branch 'AL-python-serverless' into integration
aloftus23 Nov 21, 2024
1ac576c
Fix bugs with merge
aloftus23 Nov 21, 2024
7cbd6bf
Leave out elasticache endpoints for now
aloftus23 Nov 21, 2024
c840f6d
Lock down elasticsearch version
aloftus23 Nov 21, 2024
d24e57d
Make sure acceptTerms endpoint is defined correctly
aloftus23 Nov 21, 2024
1173ed4
Add JWT env variables
aloftus23 Nov 21, 2024
fb84c53
Make sure JWT timeout is passing an int
aloftus23 Nov 21, 2024
570f9a3
Fix GET saved-search to match the frontend
aloftus23 Nov 21, 2024
9e73c06
Fix accept terms endpoint
aloftus23 Nov 21, 2024
1a29dd2
Update make file to exclude Migrate in pytest
aloftus23 Dec 2, 2024
33dbaed
Fix user registration process
aloftus23 Dec 5, 2024
565e597
Add ID to "create scan" return
aloftus23 Dec 5, 2024
b663ca9
Fix User serialization and pendingDomains in Get organization
aloftus23 Dec 5, 2024
2b0dc22
Run pre-commit
aloftus23 Dec 5, 2024
6338cd4
Fix updating an organization
aloftus23 Dec 5, 2024
e7deb34
Fix createdBy return in organization update
aloftus23 Dec 5, 2024
5f4cdd8
Set vulnerabilities to delete on cascade with domains
aloftus23 Dec 5, 2024
c9849ee
Add swagger to CSP
aloftus23 Dec 5, 2024
2c13b19
Update Cognito to use local Okta creds for dev.example.env
aloftus23 Dec 5, 2024
29c4bb9
Fix user and organization endpoints
aloftus23 Dec 6, 2024
3301fc6
Adjust Tags in views.py for Organization and Consistency.
Matthew-Grayson Dec 8, 2024
8375632
Add tags to /vulnerabilities/export endpoint.
Matthew-Grayson Dec 8, 2024
c2e394f
Fixed update saved search endpoint from performing an incorrect name …
chrtorres Dec 9, 2024
40a37a4
Updated saved search POST request to allow storage of multiple fitlers
chrtorres Dec 9, 2024
338fcc9
Fixed PUT request for saved search, allows adding multiple filters to…
chrtorres Dec 9, 2024
833e875
Merge remote-tracking branch 'origin/integration' into CT-saved-searc…
chrtorres Dec 9, 2024
a772cb4
Fixed saved search unit tests after merging python backend into integ…
chrtorres Dec 9, 2024
2fa929a
Fix lambda path to run python scheduler instead of typescript
aloftus23 Dec 10, 2024
dbf4ae8
Add django.setup to scheduler lambda
aloftus23 Dec 10, 2024
30f9d66
Code cleanup
chrtorres Dec 10, 2024
bca5f6d
Removed stray print statements
chrtorres Dec 10, 2024
3afe14f
Merge remote-tracking branch 'origin/integration' into CT-saved-searc…
chrtorres Dec 10, 2024
420f0a9
Setup worker to run python version of searchSync and fix search endpo…
aloftus23 Dec 11, 2024
c9a0a10
Add deploy worker back to integration workflow
aloftus23 Dec 11, 2024
ae6d409
Remove unused node packages
aloftus23 Dec 11, 2024
4309988
Add slim and strip to python build and excluded boto3
aloftus23 Dec 11, 2024
e457a57
Force deploy on integration
aloftus23 Dec 11, 2024
11722ff
Use existing lambda IAM role
aloftus23 Dec 11, 2024
7bebe7b
Use existing log group
aloftus23 Dec 11, 2024
2cc9d6f
Retain existing lambdas
aloftus23 Dec 11, 2024
f902bb7
Revert serverless changes
aloftus23 Dec 12, 2024
8b07f7a
Fix unknown import in views and run pre-commits
aloftus23 Dec 12, 2024
7df31d3
Pip freeze the backend container and add exact piptree to requirements
aloftus23 Dec 12, 2024
e0a48ad
Set lambda "strip: true" to false
aloftus23 Dec 12, 2024
d41b814
Remove slim and strip entirely
aloftus23 Dec 12, 2024
5acb5b6
Fix test cases and tested methods for domains and vulnerabilities.
JCantu248 Dec 12, 2024
7a21b2a
Merge branch 'integration' of github.com:cisagov/XFD into JD-add-requ…
JCantu248 Dec 12, 2024
c13b0c0
Merge pull request #737 from cisagov/CT-saved-search-fix
chrtorres Dec 12, 2024
9125c02
Fix stats to handle filters
aloftus23 Dec 12, 2024
2a6bba4
Merge branch 'integration' into AL-fix-integration-bugs
aloftus23 Dec 12, 2024
6eb2e49
Merge pull request #743 from cisagov/AL-fix-integration-bugs
aloftus23 Dec 12, 2024
501018c
Add elasticache endpoint
aloftus23 Dec 12, 2024
6dd66d5
Fix duplicate elasticache variable
aloftus23 Dec 12, 2024
a823723
Remove duplicate elasticache variable
aloftus23 Dec 12, 2024
00967c1
Make sure cache lambdas are defined correctly
aloftus23 Dec 12, 2024
01de861
Run pre-commit
aloftus23 Dec 12, 2024
7d5a018
Make sure django is imported below the environment setup
aloftus23 Dec 12, 2024
be1c42d
Add debugging logs
aloftus23 Dec 12, 2024
dde89d6
Move django setup in lambdas
aloftus23 Dec 12, 2024
b1cb234
Fix lambda parameters: needs event and context
aloftus23 Dec 13, 2024
c6b38ac
Make sure org id is in returned in /users/me
aloftus23 Dec 13, 2024
786c5d8
Add created/updated at to searchSync
aloftus23 Dec 13, 2024
2571e72
Alphabetize endpoints by tag; change P&E Proxy tag to Analytics.
Matthew-Grayson Dec 13, 2024
d94fe27
Revert changes to views.py and apply changes to views.py from integra…
Matthew-Grayson Dec 13, 2024
0584760
Merge branch 'integration' of github.com:cisagov/XFD into 734-fix-swa…
Matthew-Grayson Dec 13, 2024
b914457
Merge branch 'integration' into JD-add-request-field-to-response
aloftus23 Dec 18, 2024
1cb9902
Run pre-commit
aloftus23 Dec 18, 2024
b5a1697
Adjust Tags in views.py for Organization and Consistency.
Matthew-Grayson Dec 18, 2024
ecc7abe
Fix get vuln and export domain/vuln and make sure search has all rela…
aloftus23 Dec 18, 2024
240f453
Merge pull request #742 from cisagov/JD-add-request-field-to-response
aloftus23 Dec 18, 2024
b67b43d
Fix DMZ/LZ automation and stats
aloftus23 Dec 19, 2024
02b3c91
Change 'Analytics' label to 'Analytic Endpoints' for consistency.
Matthew-Grayson Dec 20, 2024
68bd4e5
Merge branch 'integration' of github.com:cisagov/XFD into 734-fix-swa…
Matthew-Grayson Dec 26, 2024
815844a
Fix domain tests
aloftus23 Jan 2, 2025
b4dd485
Fix org tests
aloftus23 Jan 2, 2025
2eec376
Fix remaining failing tests and pre-commits
aloftus23 Jan 2, 2025
908e556
Merge remote-tracking branch 'origin/734-fix-swagger-tags' into integ…
aloftus23 Jan 2, 2025
daa03ac
Fix elasticache too many files and logging middleware
aloftus23 Jan 2, 2025
aec707a
Convert updateScanTaskStatus and CheckUserExpiration lambdas into python
aloftus23 Jan 2, 2025
ed09b56
Add scanExecution to python backend
aloftus23 Jan 2, 2025
6c5db5f
Run pre-commit checks
aloftus23 Jan 2, 2025
85bdc9a
Remove include/exclude from lambdas as they're set globally in custom
aloftus23 Jan 2, 2025
24069de
Add more packages that are only needed for local to the noDeploy list
aloftus23 Jan 3, 2025
23708a5
Remove deprecated lambdas
aloftus23 Jan 3, 2025
99f50bb
Force integration stack update
aloftus23 Jan 3, 2025
d8f9064
Make sure docs is correctly accessible with /docs and fix scan log times
aloftus23 Jan 3, 2025
084dc8f
Merge branch 'develop' into integration
aloftus23 Jan 3, 2025
d3d1a9c
Create vulnSync and cveSync scans
aloftus23 Jan 3, 2025
fbf0cc0
Run pre-commit
aloftus23 Jan 3, 2025
08093d5
Fix all the pylints
aloftus23 Jan 3, 2025
2baf06c
Add serverless prune versions to lambda
aloftus23 Jan 3, 2025
80e2bfc
Make sure to prune old lambda versions in the frontend too
aloftus23 Jan 3, 2025
fc33e8b
Add build docs to frontend workflow
aloftus23 Jan 3, 2025
87c5098
Update the python path in pylint
aloftus23 Jan 3, 2025
14008b8
Fix backend workflow packaging test
aloftus23 Jan 3, 2025
c75339a
Disable EC2 metadata for sls package test
aloftus23 Jan 3, 2025
effe590
use serverless instead of sls for package
aloftus23 Jan 3, 2025
ec650eb
Make sure webpack-cli is installed and use make pylint
aloftus23 Jan 3, 2025
096631c
Fix build-worker and move pylint into tests
aloftus23 Jan 3, 2025
57fbd4b
Fix backend.yml
aloftus23 Jan 3, 2025
9f73f2e
Fix pre-commits
aloftus23 Jan 3, 2025
21a28ae
Ensure staging-cd is defined correctly in workflows
aloftus23 Jan 3, 2025
3c2f9ee
Force deployment of backend lambdas
aloftus23 Jan 3, 2025
59f221f
Re-add bandit and flake and fix anything breaking
aloftus23 Jan 3, 2025
5b8b05d
Add debug steps to frontend.yml
aloftus23 Jan 6, 2025
3bdaeda
Make sure to set docs working dir in frontend build
aloftus23 Jan 6, 2025
f1b1dce
Add step verifying directory structure to frontend build
aloftus23 Jan 6, 2025
ac5585f
Remove default working directory and use explicit in frontend worflows
aloftus23 Jan 6, 2025
5633d5e
Allow frontend API to invoke docs lambda
aloftus23 Jan 6, 2025
8b75fc4
Make sure /docs/* endpoints stay in the gatsby app
aloftus23 Jan 6, 2025
52b0fe9
Re-add policy allowing api gateway to invoke docs lambda
aloftus23 Jan 6, 2025
789b972
Make sure all the subpaths of docs is allowed in invoke permission
aloftus23 Jan 6, 2025
1b7e497
Allow docs to route multiple pages
aloftus23 Jan 6, 2025
0a089ac
Fix docs page
aloftus23 Jan 6, 2025
393e572
Fix docs
aloftus23 Jan 6, 2025
e9e1ea5
Fix code scanning alert no. 205: Uncontrolled data used in path expre…
aloftus23 Jan 6, 2025
e6dd336
Update docs
aloftus23 Jan 6, 2025
72b185e
Fix code scanning alert no. 205: Uncontrolled data used in path expre…
aloftus23 Jan 6, 2025
81426f8
Make the docs/* dynamic
aloftus23 Jan 6, 2025
84c29fd
Add fs to import in docs.js
aloftus23 Jan 6, 2025
995fdfb
UPdate docs CSP
aloftus23 Jan 6, 2025
d68c667
Fix docs.js suggested security issues
aloftus23 Jan 6, 2025
934f8f6
Fix code scanning alert no. 208: Uncontrolled data used in path expre…
aloftus23 Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
tests:

skips:
- B101 # skip "assert used" check since assertions are required in pytests
# Skip "assert used" check since assertions are required in pytests
- B101
# Skip "pseudo-random generators not suitable for security"
# b/c it's used for sample data
- B311
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ select = C,D,E,F,W,B,B950
# operators. It no longer agrees with PEP8. See, for example, here:
# https://github.com/ambv/black/issues/21. Guido agrees here:
# https://github.com/python/peps/commit/c59c4376ad233a62ca4b3a6060c81368bd21e85b.
ignore = E501,W503
ignore = E203,E402,E501,W503
143 changes: 48 additions & 95 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ on:
push:
branches:
- develop
- production
- integration
paths:
- backend/**
- .github/workflows/backend.yml
pull_request:
branches:
- develop
- production
- integration
paths:
- backend/**
- .github/workflows/backend.yml
Expand All @@ -22,28 +22,12 @@ defaults:
working-directory: ./backend

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Restore npm cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
Expand All @@ -55,71 +39,31 @@ jobs:
restore-keys: ${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Run site locally
run: |
cp dev.env.example .env
docker compose up -d db backend es
npm install -g wait-port
wait-port -t 3000 5432 9200 9300
python -m pip install wait-for-it
wait-for-it --service localhost:3000 --timeout=10
wait-for-it --service localhost:5432 --timeout=10
wait-for-it --service localhost:9200 --timeout=10
wait-for-it --service localhost:9300 --timeout=10
working-directory: ./

- name: Sync database
run: npm run syncdb
working-directory: ./backend
- name: Test
run: npm run test -- --collectCoverage --silent
- name: Package
run: npx sls package
env:
SLS_DEBUG: '*'
test_worker:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Restore npm cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Build
run: npx webpack --config webpack.worker.config.js
- name: Run db locally
run: |
cp dev.env.example .env
docker compose up -d db
npm install -g wait-port
wait-port -t 3000 5432
working-directory: ./
- name: Test
run: node dist/worker.bundle.js
env:
CROSSFEED_COMMAND_OPTIONS: '{"scanName": "test"}'
DB_USERNAME: crossfeed
DB_PASSWORD: password
test_python:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v5.0.0
with:
python-version: '3.10'
- name: Copy .env file
run: cp ../dev.env.example .env
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: pip-
- run: pip install -r worker/requirements.txt
- run: pytest
run: make syncdb

- name: Lint with pylint
run: make pylint

- name: Run pytest
run: make pytest

build_worker:
runs-on: ubuntu-latest
timeout-minutes: 90
Expand All @@ -139,8 +83,9 @@ jobs:
- name: Build worker container
run: npm run build-worker
working-directory: ./backend

deploy_staging:
needs: [build_worker, lint, test, test_worker, test_python]
needs: [build_worker, test]
runs-on: ubuntu-latest
environment: staging
concurrency: '1'
Expand All @@ -150,6 +95,10 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Restore npm cache
uses: actions/cache@v3
with:
Expand All @@ -160,14 +109,14 @@ jobs:
run: npm ci

- name: Ensure domain exists
run: npx sls create_domain --stage=staging
run: npx sls create_domain --stage=staging-cd
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SLS_DEBUG: '*'

- name: Deploy backend
run: npx sls deploy --stage=staging
run: npx sls deploy --stage=staging-cd
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -182,7 +131,7 @@ jobs:

- name: Run syncdb
run: |
aws lambda invoke --function-name crossfeed-staging-syncdb \
aws lambda invoke --function-name crossfeed-staging-cd-syncdb \
--region us-east-1 /dev/stdout
working-directory: backend
env:
Expand All @@ -191,24 +140,28 @@ jobs:

- name: Run syncmdl
run: |
aws lambda invoke --function-name crossfeed-staging-syncmdl \
aws lambda invoke --function-name crossfeed-staging-cd-syncmdl \
--region us-east-1 /dev/stdout
working-directory: backend
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

deploy_prod:
needs: [build_worker, lint, test, test_python]
deploy_integration:
needs: [build_worker, test]
runs-on: ubuntu-latest
environment: production
environment: integration
concurrency: '1'
if: github.event_name == 'push' && github.ref == 'refs/heads/production'
if: github.event_name == 'push' && github.ref == 'refs/heads/integration'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Restore npm cache
uses: actions/cache@v3
with:
Expand All @@ -219,39 +172,39 @@ jobs:
run: npm ci

- name: Ensure domain exists
run: npx sls create_domain --stage=prod
run: npx sls create_domain --stage=integration
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SLS_DEBUG: '*'

- name: Deploy backend
run: npx sls deploy --stage=prod
run: npx sls deploy --stage=integration --force
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SLS_DEBUG: '*'

- name: Deploy worker
run: npm run deploy-worker-prod
run: npm run deploy-worker-integration
working-directory: backend
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Run syncdb
run: |
aws lambda invoke --function-name crossfeed-prod-syncdb --region us-east-1 \
/dev/stdout
aws lambda invoke --function-name crossfeed-integration-syncdb \
--region us-east-1 /dev/stdout
working-directory: backend
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Run syncmdl
run: |
aws lambda invoke --function-name crossfeed-prod-syncmdl --region us-east-1 \
/dev/stdout
aws lambda invoke --function-name crossfeed-integration-syncmdl \
--region us-east-1 /dev/stdout
working-directory: backend
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CodeQL

on:
push:
branches: [develop, production]
branches: [develop, integration]
pull_request:
branches: [develop]
schedule:
Expand Down
Loading
Loading