Skip to content

Commit e5a5587

Browse files
seansteberisalshweta-nhsayeshalshukri1-nhsrobbailiff2dependabot[bot]
authored
ELI-365 - over 80s (#288)
* ELI-318: Adds content-type in 404 and 500 error response (#232) * ELI-294: Personalised/customised status text (#234) * ELI-294: Personalised/customised status text * ELI-294: Personalised/customised status text * ELI-294: Adds unit tests for Status Enum * ELI-294: Fix sonar issues * ELI-318: Adds application/fhir+json as valid mime type in Mangum (#235) * ELI-331: Mask PII/GDPR info (#239) * ELI-331: Mask PII/GDPR info * ELI-331: Fix formatting * ELI-331: Fix format and lint * Revert "ELI-331: Mask PII/GDPR info (#239)" (#240) This reverts commit 14d6a5e. * Feature/eli 295 generic text for not eligible xrules (#238) * WIP: drafting out X and Y rules. * WIP: updated config with x and y rule idea. * WIP: Stub out x and y rules impl * WIP: stubbing out impl. * Refactored action support functions and renamed vars * WIP: Added X/Y Rule logic and test. * Added tests for eligible and actionable actions. * WIP: Added more tests for X and Y rule scenarios. * WIP: flaky tests. * WIP: Fixed failing tests for empty actions. * WIP: added audit record check to tests. * WIP: file format and added audit rule priority and name test. * Working tests. Refactored some audit logic. * Minor refactor * Addressed linting issues * WIP: fixed failing unit tests. * Format. * Added tests. * File format --------- Co-authored-by: Robert <rob.bailiff1@nhs.net> * Bump polyfactory from 2.21.0 to 2.22.1 --- updated-dependencies: - dependency-name: polyfactory dependency-version: 2.22.1 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Revert "Bump polyfactory from 2.21.0 to 2.22.1" (#241) * Bump aiohttp from 3.12.13 to 3.12.14 --- updated-dependencies: - dependency-name: aiohttp dependency-version: 3.12.14 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * provided appropriate values factory methods in tests (#245) * Refactor package structure (#247) * eli-343 following on from suggestions from AWS Security Hub, restricting access to public internet via Internet Gateway, and adding table protection in Prod for DynamoDB * add lambda request id in logs events (#248) * add lambda request id in logs events * linting fix * revoked custom formatter and reapplied JsonFormatter * revoked formatting * added wrapper for registering requestid * Adds unit tests for log format --------- Co-authored-by: Shweta <216860557+shweta-nhs@users.noreply.github.com> * Feature/rgjb aa eli 329 add xray tracing for lambda (#243) * Added xray permissions policy for lambda * Add xray vpc endpoint * Added xray to the permissions boundary * Added xray to the assumed role permissions boundary * Testing permission boundary. * testing perm bound. --------- Co-authored-by: ayeshalshukri1-nhs <112615598+ayeshalshukri1-nhs@users.noreply.github.com> * bugfix - Github action needs permission to modify public access block * bugfix - changing permission to be wildcard resource, as it's an account level permission * Added api gateway request id, moved request id logging to app.py (#252) * ELI-351 and ELI-342: Refactors and fixes Cohort Schema Mismatch (#253) * Adds campaign_evaluator and tests * Adds person_data_reader and tests * Injects person data reader and campaign processor into eligibility calculator * ELI-342 Dynamo Cohort Schema Mismatch * ELI-342: Fixes usage of person cohorts method and tests * Feature/eli 369 dynamodb x ray tracing (#256) * handled none headers from request * x-ray tracing setup for dynamo, s3, firehose * enable_xray_patching env variable for lambda * sonar fixes --------- Co-authored-by: karthikeyannhs <174426205+Karthikeyannhs@users.noreply.github.com> * Bump slackapi/slack-github-action from 2.1.0 to 2.1.1 Bumps [slackapi/slack-github-action](https://github.com/slackapi/slack-github-action) from 2.1.0 to 2.1.1. - [Release notes](https://github.com/slackapi/slack-github-action/releases) - [Commits](slackapi/slack-github-action@v2.1.0...v2.1.1) --- updated-dependencies: - dependency-name: slackapi/slack-github-action dependency-version: 2.1.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * ELI-351: Refactor (#254) * ELI-351: Renames rules model to campaign_config * ELI-351: Extracts Person data class * ELI-351: Adds rule processor * ELI-351: Adds tests for rule processor * ELI-351: Moves get_cohort_group_results to rule processor * ELI-351: Adds tests for rule processor * ELI-351: Adds cohort handler using Chain of responsibility pattern * ELI-351: Renames * ELI-351: Fixes lint * ELI-351: Renames evaluate_eligibility to get_eligibility_status * ELI-351: Refactoring to get better readability for chaining * ELI-351: Fix lint * Bump botocore from 1.38.42 to 1.38.46 Bumps [botocore](https://github.com/boto/botocore) from 1.38.42 to 1.38.46. - [Commits](boto/botocore@1.38.42...1.38.46) --- updated-dependencies: - dependency-name: botocore dependency-version: 1.38.46 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Bump moto from 5.1.6 to 5.1.9 Bumps [moto](https://github.com/getmoto/moto) from 5.1.6 to 5.1.9. - [Release notes](https://github.com/getmoto/moto/releases) - [Changelog](https://github.com/getmoto/moto/blob/master/CHANGELOG.md) - [Commits](getmoto/moto@5.1.6...5.1.9) --- updated-dependencies: - dependency-name: moto dependency-version: 5.1.9 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Bump localstack from 4.5.0 to 4.6.0 Bumps [localstack](https://github.com/localstack/localstack) from 4.5.0 to 4.6.0. - [Release notes](https://github.com/localstack/localstack/releases) - [Commits](localstack/localstack@v4.5.0...v4.6.0) --- updated-dependencies: - dependency-name: localstack dependency-version: 4.6.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump pytest-asyncio from 1.0.0 to 1.1.0 --- updated-dependencies: - dependency-name: pytest-asyncio dependency-version: 1.1.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump pytest-docker from 3.2.2 to 3.2.3 Bumps [pytest-docker](https://github.com/avast/pytest-docker) from 3.2.2 to 3.2.3. - [Release notes](https://github.com/avast/pytest-docker/releases) - [Changelog](https://github.com/avast/pytest-docker/blob/master/CHANGELOG.md) - [Commits](avast/pytest-docker@v3.2.2...v3.2.3) --- updated-dependencies: - dependency-name: pytest-docker dependency-version: 3.2.3 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * ELI-351: Refactor (#258) * ELI-351: Refactor * ELI-351: Adds tests for action rule handler * ELI-351: Renames and fixes tests * ELI-351: Renames and fixes tests * Bump asgiref from 3.8.1 to 3.9.1 Bumps [asgiref](https://github.com/django/asgiref) from 3.8.1 to 3.9.1. - [Changelog](https://github.com/django/asgiref/blob/main/CHANGELOG.txt) - [Commits](django/asgiref@3.8.1...3.9.1) --- updated-dependencies: - dependency-name: asgiref dependency-version: 3.9.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump gitpython from 3.1.44 to 3.1.45 Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.44 to 3.1.45. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](gitpython-developers/GitPython@3.1.44...3.1.45) --- updated-dependencies: - dependency-name: gitpython dependency-version: 3.1.45 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Bump pyright from 1.1.402 to 1.1.403 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.402 to 1.1.403. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](RobertCraigie/pyright-python@v1.1.402...v1.1.403) --- updated-dependencies: - dependency-name: pyright dependency-version: 1.1.403 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * ELI-351: Moves/deletes tests after refactoring (#265) * ELI-351: Moves/deletes tests after refactoring * ELI-351: Extracts EligibilityResultBuilder and adds tests * ELI-351: De-extracts EligibilityResultBuilder and moves tests to Eligibility Calculator tests * ELI-351: Removes duplicated tests * ELI-351: Removes duplicated tests #2 * ELI-351: Adds validation and audit layer to Readme * Bump aiohttp from 3.12.14 to 3.12.15 --- updated-dependencies: - dependency-name: aiohttp dependency-version: 3.12.15 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * trying an approach to ensure correct version of python used in lambda build (#271) * ELI-311: Campaign Config Data Type Changes (#269) * eli-285 and eli-349 adding cloudwatch alarms for a) security and b) ops - API Gateway and Lambda execution * eli-285 - disabling action on API calls as our internal security are triggering this * eli-285 and 349 adding kms for sns, checkov skip for disabled alarms * work in progress * eli-285 enable kms key rotation * eli-285 get rid of false flag gitleak * eli-388 adding access log permissions for audit buckets * eli-386 blocking s3 public access at account level * ELI-376: Audit record should log multiple F and S rules (#275) * ELI-376: Audit record should log multiple F and S rules * ELI-376: Fixing int test * ELI-150: campaign config validation (#264) * validations - wip * iteration validation * iteration rules * campaign config validation * made BUC tests bit more clear * Renaming for clarity. * lint and formatting fixes. * wip * Integration Rules Test * Actions mapper validator * Iterations BUC * available_actions tests * lint fixes * lint fixes * Bump asgiref from 3.8.1 to 3.9.1 Bumps [asgiref](https://github.com/django/asgiref) from 3.8.1 to 3.9.1. - [Changelog](https://github.com/django/asgiref/blob/main/CHANGELOG.txt) - [Commits](django/asgiref@3.8.1...3.9.1) --- updated-dependencies: - dependency-name: asgiref dependency-version: 3.9.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Bump gitpython from 3.1.44 to 3.1.45 Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.44 to 3.1.45. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](gitpython-developers/GitPython@3.1.44...3.1.45) --- updated-dependencies: - dependency-name: gitpython dependency-version: 3.1.45 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Bump pyright from 1.1.402 to 1.1.403 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.402 to 1.1.403. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](RobertCraigie/pyright-python@v1.1.402...v1.1.403) --- updated-dependencies: - dependency-name: pyright dependency-version: 1.1.403 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * ELI-351: Moves/deletes tests after refactoring (#265) * ELI-351: Moves/deletes tests after refactoring * ELI-351: Extracts EligibilityResultBuilder and adds tests * ELI-351: De-extracts EligibilityResultBuilder and moves tests to Eligibility Calculator tests * ELI-351: Removes duplicated tests * ELI-351: Removes duplicated tests #2 * ELI-351: Adds validation and audit layer to Readme * wip - has failing tests * test fixed and lint error fixed * warning fixed * rules validation added * test commit * tests updated w.r.t to datatype changes from main * updated output message * arguments added to app.py * sonar fix * sonar fix * sonar fix --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: karthikeyannhs <174426205+Karthikeyannhs@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Shweta <216860557+shweta-nhs@users.noreply.github.com> * eli-386 adding github permissions to make account level public access block changes * all tests passing * Revert "eli-386 blocking s3 public access at account level" * extracting method for readability * ELI-399: Fixing Future Iteration.StartDate Resulting in 500 Error (#282) * ELI-399: Fixing Future Iteration.StartDate Resulting in 500 Error * ELI-399: Adds empty rules to fix flakiness * applying to filter rules and adding test * ELI-397: Fixing nhs number missing from path error to be FHIR compliant (#284) * Added new tests updated poetry version * ELI-399: Fixing start date validation (#287) * ELI-399: Fixing start date validation * ELI-399: Fixing annotation * ELI-328: cohort validations (#281) * test action mapper doesn't accept invalid actions * Attribute level and name relations when it is cohort * added iteration_cohorts_validation * chainging the validations * fix * fix * fix lint * fix lint * lint fixes * lint fixes * test fixes * lint fixes * Removed defaultcomms from iteration level of test config. * Reorder feilds in config. * Update to config. * default comm routing validation * unit tests default comm routing validation * default comm routing validation in rules * lint fixes * test data fixed * grouped model validators --------- Co-authored-by: ayeshalshukri1-nhs <112615598+ayeshalshukri1-nhs@users.noreply.github.com> * fixed new tests * ELI-404: Fix Error message returned for authorisation failure (#289) * ELI-404: Fix Error message returned for authorisation failure * ELI-404: Fix sonar * update packages * Bugfix to change response grouping from name to priority (#286) * changed grouping from name to priority * changed grouping from name to priority, type * sonar code complexity fix * sonar code complexity fix * updated names in the code for better clarity * regroup the suitability tests * fix - ordering regroup the suitability tests * test for cohort groups --------- Co-authored-by: karthikeyannhs <174426205+Karthikeyannhs@users.noreply.github.com> * ELI-397: AWS api gateway to handle bad request param error (#291) * Changes to tests added 1 more test fixed 365 config to work with all test cases * linting and formatting update package updates --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Shweta <216860557+shweta-nhs@users.noreply.github.com> Co-authored-by: ayeshalshukri1-nhs <112615598+ayeshalshukri1-nhs@users.noreply.github.com> Co-authored-by: Robert <rob.bailiff1@nhs.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: eddalmond1 <edd.almond1@nhs.net> Co-authored-by: Karthikeyannhs <174426205+Karthikeyannhs@users.noreply.github.com> Co-authored-by: eddalmond1 <102675624+eddalmond1@users.noreply.github.com> Co-authored-by: TOEL2 <tom.eldridge1@nhs.net>
1 parent 8e0f86f commit e5a5587

127 files changed

Lines changed: 7536 additions & 4222 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cicd-2-publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ jobs:
141141
# asset_name: lambda-${{ needs.metadata.outputs.version }}.zip
142142
# asset_content_type: application/zip
143143
- name: "Notify Slack on PR merge"
144-
uses: slackapi/slack-github-action@v2.1.0
144+
uses: slackapi/slack-github-action@v2.1.1
145145
with:
146146
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
147147
webhook-type: webhook-trigger

.tool-versions

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
terraform 1.12.1
44
pre-commit 4.2.0
55
vale 3.11.2
6-
poetry 2.1.3
6+
poetry 2.1.4
77
act 0.2.77
8+
nodejs 22.18.0
89

910
# ==============================================================================
1011
# The section below is reserved for Docker image versions.

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,25 @@ graph TB
189189
direction TB
190190
App["app.py (WireUp DI)"]
191191
Config["config.py, error_handler.py"]
192+
subgraph "Audit Layer"
193+
direction TB
194+
Audit["audit/audit_service.py"]
195+
AuditModels["audit/audit_models.py"]
196+
end
197+
subgraph "Validation Layer"
198+
direction TB
199+
Validator["common/request_validator.py"]
200+
ApiErrResp["common/api_error_response.py"]
201+
end
192202
subgraph "Presentation Layer"
193203
direction TB
194204
View["views/eligibility.py"]
195-
ResponseModel["views/response_model/eligibility.py"]
205+
ResponseModel["views/response_model/eligibility_response.py"]
196206
end
197207
subgraph "Business Logic Layer"
198208
direction TB
199209
Service["services/eligibility_services.py"]
200-
Operators["services/rules/operators.py"]
210+
Operators["services/operators/operators.py"]
201211
end
202212
subgraph "Data Access Layer"
203213
direction TB
@@ -207,24 +217,30 @@ graph TB
207217
end
208218
subgraph "Models"
209219
direction TB
210-
ModelElig["model/eligibility.py"]
211-
ModelRules["model/rules.py"]
220+
ModelElig["model/eligibility_status.py"]
221+
ModelRules["model/campaign_config.py"]
212222
end
213223
end
214224
215225
Lambda -->|"loads"| App
216226
App -->|injects| View
217227
View -->|calls| Service
228+
View -->|validates via| Validator
229+
View -->|audits via| Audit
230+
View -->|uses| RespModel
231+
Audit -->|uses| AuditModels
232+
Validator -->|uses| ApiErrResp
233+
218234
Service -->|calls| Operators
219235
Service -->|calls| PersonRepo
220236
Service -->|calls| CampaignRepo
221237
PersonRepo -->|uses| DynamoDB
222238
CampaignRepo -->|uses| S3Bucket
223-
View -->|uses| ResponseModel
224239
App -->|reads| Config
240+
App -->|wires| Factory
241+
225242
Service -->|uses| ModelElig
226243
Operators -->|uses| ModelRules
227-
App -->|wires| Factory
228244
229245
```
230246

infrastructure/modules/dynamodb/dynamodb.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ resource "aws_dynamodb_table" "dynamodb_table" {
22
name = "${terraform.workspace == "default" ? "" : "${terraform.workspace}-"}${var.project_name}-${var.environment}-${var.table_name_suffix}"
33
billing_mode = "PAY_PER_REQUEST"
44
hash_key = var.partition_key
5+
deletion_protection_enabled = var.environment == "prod"
56

67
attribute {
78
name = var.partition_key

infrastructure/modules/lambda/lambda.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ resource "aws_lambda_function" "eligibility_signposting_lambda" {
2222
KINESIS_AUDIT_STREAM_TO_S3 = var.kinesis_audit_stream_to_s3_name
2323
ENV = var.environment
2424
LOG_LEVEL = var.log_level
25+
ENABLE_XRAY_PATCHING = var.enable_xray_patching
2526
}
2627
}
2728

infrastructure/modules/lambda/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ variable "log_level" {
4747
description = "log level"
4848
type = string
4949
}
50+
51+
variable "enable_xray_patching"{
52+
description = "flag to enable xray tracing, which puts an entry for dynamodb, s3 and firehose in trace map"
53+
type = string
54+
}

infrastructure/modules/s3/s3.tf

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,57 @@ data "aws_iam_policy_document" "access_logs_s3_bucket_policy" {
105105
variable = "aws:SecureTransport"
106106
}
107107
}
108+
109+
# Allow S3 Log Delivery service to write access logs
110+
statement {
111+
sid = "S3ServerAccessLogsPolicy"
112+
effect = "Allow"
113+
principals {
114+
type = "Service"
115+
identifiers = ["logging.s3.amazonaws.com"]
116+
}
117+
actions = [
118+
"s3:PutObject"
119+
]
120+
resources = [
121+
"${aws_s3_bucket.storage_bucket_access_logs.arn}/*"
122+
]
123+
condition {
124+
test = "ArnEquals"
125+
variable = "aws:SourceArn"
126+
values = [aws_s3_bucket.storage_bucket.arn]
127+
}
128+
}
129+
130+
# Allow S3 Log Delivery service to check bucket location and get bucket ACL
131+
statement {
132+
sid = "S3ServerAccessLogsDeliveryRootAccess"
133+
effect = "Allow"
134+
principals {
135+
type = "Service"
136+
identifiers = ["logging.s3.amazonaws.com"]
137+
}
138+
actions = [
139+
"s3:GetBucketAcl",
140+
"s3:ListBucket"
141+
]
142+
resources = [
143+
aws_s3_bucket.storage_bucket_access_logs.arn
144+
]
145+
condition {
146+
test = "ArnEquals"
147+
variable = "aws:SourceArn"
148+
values = [aws_s3_bucket.storage_bucket.arn]
149+
}
150+
}
108151
}
109152

110153
resource "aws_s3_bucket_server_side_encryption_configuration" "storage_bucket_access_logs_server_side_encryption_config" {
111154
bucket = aws_s3_bucket.storage_bucket_access_logs.id
112155

113156
rule {
114157
apply_server_side_encryption_by_default {
115-
sse_algorithm = "aws:kms"
158+
sse_algorithm = "aws:kms"
116159
kms_master_key_id = aws_kms_key.storage_bucket_cmk.arn
117160
}
118161
}

infrastructure/stacks/api-layer/assumed_role_permissions_boundary.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ data "aws_iam_policy_document" "assumed_role_permissions_boundary" {
3333
"support:*",
3434
"sqs:*",
3535
"tag:*",
36-
"trustedadvisor:*"
36+
"trustedadvisor:*",
37+
"xray:*"
3738
]
3839

3940
resources = ["*"]

0 commit comments

Comments
 (0)