Skip to content

Source of Truth - Long Tracking Branch#4765

Merged
jrothacker merged 189 commits into
mainfrom
jr/source-of-truth/main
Apr 7, 2025
Merged

Source of Truth - Long Tracking Branch#4765
jrothacker merged 189 commits into
mainfrom
jr/source-of-truth/main

Conversation

@jrothacker
Copy link
Copy Markdown
Contributor

Purpose

This PR will begin creating and updating Audits in the new Audit table.

How

Audit should now be wired into everything all the way through to dissemination. Search and all UIs are still reliant on SAC/dissemination tables.

Testing

Linting, Unit Tests, End to End tests

Notes

I truly apologize about the size of this PR.
There is a large refactor as part of this change.
I will want to do additional thorough manual testing before we move this to production.
Due to the nature of this change, I'm going to request 2 approvals before I merge.

This was originally here: #4737 it got closed when renaming the branch

jrothacker and others added 11 commits March 3, 2025 12:05
- Address feedback where we no longer need`_convert_additional_fields()` - it is a duplicate of a method in `utils.py`.
- Minor cleanup on `_populate_accesses()`. I no longer felt it needed to be an isolated function while addressing the above bullet point
- Supplied two new arguments, "--disseminated" and "--intake". The first will only fetch SAC data that is disseminated, while the second will only fetch SAC data that has not yet disseminated.
- Rather than iterate through 50k SACs at a time, this change introduces a while condition that will continuously migrate batches of 100 until all relevant SACs are migrated. This should mean we only need to run the command once at a time.
Bandit does not like potential SQL injection with string-based query construction, however this logic is only accessed internally.
- Added `migrated_to_audit` flag on `SingleAuditChecklist` for determining which SACs have not yet been migrated.
- Added some logic (for local testing ONLY) which cleans up audit data and references to mimic a clean slate.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 10, 2025

Terraform plan for meta

No changes. Your infrastructure matches the configuration.
No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

✅ Plan applied in Deploy to Development and Management Environment #973

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 10, 2025

Terraform plan for dev

Plan: 1 to add, 4 to change, 1 to destroy.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
!~  update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.dev.cloudfoundry_network_policy.app-network-policy will be updated in-place
!~  resource "cloudfoundry_network_policy" "app-network-policy" {
        id = "99884884-59ae-8864-786d-a5e33d1b1455"

-       policy {
-           destination_app = "ea09b23c-eebc-4383-9f4d-29152236ad87" -> null
-           port            = "61443" -> null
-           protocol        = "tcp" -> null
-           source_app      = "bfcc67a1-8ace-45fe-b472-0594da8ab39b" -> null
        }
-       policy {
-           destination_app = "ea09b23c-eebc-4383-9f4d-29152236ad87" -> null
-           port            = "61443" -> null
-           protocol        = "tcp" -> null
-           source_app      = "d7fcdc7a-fd97-4e31-89ae-b823883b5992" -> null
        }
+       policy {
+           destination_app = (known after apply)
+           port            = "61443"
+           protocol        = "tcp"
+           source_app      = "bfcc67a1-8ace-45fe-b472-0594da8ab39b"
        }
+       policy {
+           destination_app = (known after apply)
+           port            = "61443"
+           protocol        = "tcp"
+           source_app      = "d7fcdc7a-fd97-4e31-89ae-b823883b5992"
        }
    }

  # module.dev.cloudfoundry_network_policy.clamav-network-policy will be updated in-place
!~  resource "cloudfoundry_network_policy" "clamav-network-policy" {
        id = "30fc72e9-9a5e-c40d-140c-98bc1b576989"

-       policy {
-           destination_app = "a6eb3870-2769-4aa9-a8f2-f1a31939f563" -> null
-           port            = "61443" -> null
-           protocol        = "tcp" -> null
-           source_app      = "6eab89ac-271f-4193-893f-cfa1f590f3d9" -> null
        }
-       policy {
-           destination_app = "a6eb3870-2769-4aa9-a8f2-f1a31939f563" -> null
-           port            = "61443" -> null
-           protocol        = "tcp" -> null
-           source_app      = "ea09b23c-eebc-4383-9f4d-29152236ad87" -> null
        }
+       policy {
+           destination_app = "a6eb3870-2769-4aa9-a8f2-f1a31939f563"
+           port            = "61443"
+           protocol        = "tcp"
+           source_app      = (known after apply)
        }
+       policy {
+           destination_app = "a6eb3870-2769-4aa9-a8f2-f1a31939f563"
+           port            = "61443"
+           protocol        = "tcp"
+           source_app      = (known after apply)
        }
    }

  # module.dev.module.clamav.cloudfoundry_app.clamav_api will be updated in-place
!~  resource "cloudfoundry_app" "clamav_api" {
+       buildpacks                      = (known after apply)
!~      created_at                      = "2025-03-14T14:22:42Z" -> (known after apply)
!~      docker_image                    = "ghcr.io/gsa-tts/fac/clamav@sha256:296c46bb74c5a29e4b71aa0d46a8518dd379b4410026a9a3ab97b0ea8fc7b4bd" -> "ghcr.io/gsa-tts/fac/clamav@sha256:613e32da4c4c3207cf8f1e7ed7f04f0a34f4db14b7404f3cc0b6bf78be90fad8"
!~      health_check_type               = "port" -> (known after apply)
!~      id                              = "************************************" -> (known after apply)
!~      log_rate_limit_per_second       = "-1" -> (known after apply)
        name                            = "fac-av-dev"
!~      readiness_health_check_type     = "process" -> (known after apply)
!~      stack                           = null -> (known after apply)
!~      updated_at                      = "2025-03-31T12:19:40Z" -> (known after apply)
#        (9 unchanged attributes hidden)
    }

  # module.dev.module.cors.null_resource.cors_header must be replaced
-/+ resource "null_resource" "cors_header" {
!~      id       = "*******************" -> (known after apply)
!~      triggers = { # forces replacement
!~          "always_run" = "2025-04-02T19:23:28Z" -> (known after apply)
        }
    }

  # module.dev.module.file_scanner_clamav.cloudfoundry_app.clamav_api will be updated in-place
!~  resource "cloudfoundry_app" "clamav_api" {
+       buildpacks                      = (known after apply)
!~      created_at                      = "2025-03-14T14:22:42Z" -> (known after apply)
!~      docker_image                    = "ghcr.io/gsa-tts/fac/clamav@sha256:296c46bb74c5a29e4b71aa0d46a8518dd379b4410026a9a3ab97b0ea8fc7b4bd" -> "ghcr.io/gsa-tts/fac/clamav@sha256:613e32da4c4c3207cf8f1e7ed7f04f0a34f4db14b7404f3cc0b6bf78be90fad8"
!~      health_check_type               = "port" -> (known after apply)
!~      id                              = "************************************" -> (known after apply)
!~      log_rate_limit_per_second       = "-1" -> (known after apply)
        name                            = "fac-av-dev-fs"
!~      readiness_health_check_type     = "process" -> (known after apply)
!~      stack                           = null -> (known after apply)
!~      updated_at                      = "2025-03-31T12:19:41Z" -> (known after apply)
#        (9 unchanged attributes hidden)
    }

Plan: 1 to add, 4 to change, 1 to destroy.

✅ Plan applied in Deploy to Development and Management Environment #973

Comment thread backend/audit/views/excel_file_handler.py Dismissed
Comment thread backend/audit/views/excel_file_handler.py Dismissed
Comment thread backend/audit/views/excel_file_handler.py Dismissed
Comment thread backend/audit/views/excel_file_handler.py Dismissed
jrothacker and others added 3 commits March 10, 2025 17:15
- Updated `generate_audit_indexes` to catch an issue where `auditee_fiscal_period_end` is an empty string for some records.
- `migrate_audits` command now uses ORM instead of raw queries for performance improvements.
- Improved logging of `migrate_audits` for better monitoring of progress.
- Inserted `null=True` into `migrated_to_audit` booleanfield for SACs.
- Setting `migrated_to_audit=True` for SACs that get created during intake process. This is because an Audit already gets created with the SAC during this step.
Updating mixins to account for audits
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2025

This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging.

Comment thread backend/api/serializers/uei.py Dismissed
jrothacker and others added 24 commits April 3, 2025 12:19
Updating the previous references validation to use Audit table
We fixed a number of things in the comparison script, and like where we
are.

One fix in the API.

Ready for iteration.
Ignoring the test file, adding a timeout to `get()`.
…-date

Do the date calculations for fac-accepted-date
Copy link
Copy Markdown
Contributor

@jadudm jadudm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch has seen extensive ongoing review; it was a long-lived branch during March while we waited for the busy season to end. Bringing into main for further development and testing.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2025

Code Coverage

Package Line Rate Branch Rate Health
. 100% 100%
api 99% 87%
api.serializers 97% 88%
api.views 91% 100%
audit 95% 80%
audit.cross_validation 97% 85%
audit.fixtures 84% 50%
audit.intakelib 89% 83%
audit.intakelib.checks 92% 85%
audit.intakelib.common 98% 82%
audit.intakelib.transforms 100% 95%
audit.management.commands 78% 17%
audit.migrations 100% 100%
audit.models 92% 62%
audit.templatetags 100% 100%
audit.views 74% 55%
census_historical_migration 96% 65%
census_historical_migration.migrations 100% 100%
census_historical_migration.sac_general_lib 92% 84%
census_historical_migration.transforms 95% 90%
census_historical_migration.workbooklib 68% 69%
config 77% 37%
curation 100% 100%
curation.curationlib 93% 100%
curation.migrations 100% 100%
dissemination 91% 69%
dissemination.migrations 97% 25%
dissemination.report_generation 29% 0%
dissemination.report_generation.excel 32% 0%
dissemination.searchlib 59% 41%
dissemination.templatetags 100% 100%
dissemination.views 76% 55%
djangooidc 53% 38%
djangooidc.tests 100% 94%
report_submission 100% 95%
report_submission.migrations 100% 100%
report_submission.templatetags 74% 100%
report_submission.views 77% 63%
support 93% 74%
support.migrations 100% 100%
support.models 90% 50%
tools 98% 50%
users 95% 92%
users.fixtures 100% 83%
users.management 100% 100%
users.management.commands 100% 100%
users.migrations 100% 100%
Summary 89% (19951 / 22384) 71% (2428 / 3440)

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.

9 participants