diff --git a/.trivyignore b/.trivyignore index 69194e68..dddbad2d 100644 --- a/.trivyignore +++ b/.trivyignore @@ -18,6 +18,7 @@ CVE-2021-35515 CVE-2021-35516 CVE-2021-35517 CVE-2021-36090 +CVE-2026-33180 # upgrading fasterxml-core to fixed version 2.21.1 appears to not # be compatible with 2.19.2 of fasterxml-annotations GHSA-72hv-8253-57qq diff --git a/src/main/java/software/nhs/fhirvalidator/controller/ValidateController.java b/src/main/java/software/nhs/fhirvalidator/controller/ValidateController.java index d53bc995..9fdfa4b6 100644 --- a/src/main/java/software/nhs/fhirvalidator/controller/ValidateController.java +++ b/src/main/java/software/nhs/fhirvalidator/controller/ValidateController.java @@ -11,7 +11,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.OperationOutcome; -import org.hl7.fhir.r4.model.ResourceType; import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent; import ca.uhn.fhir.context.FhirContext; @@ -80,7 +79,8 @@ public OperationOutcome parseAndValidateResource(String input) { | DataFormatException e) { log.error(e.toString()); return OperationOutcomeUtils - .createOperationOutcome(e.getMessage() != null ? e.getMessage() : "Invalid JSON", null); + .createOperationOutcome((e.getMessage() != null && !(e instanceof NullPointerException)) + ? e.getMessage() : "Invalid JSON", null); } } @@ -101,15 +101,10 @@ private List getResourcesToValidate(IBaseResource inputResource) if (inputResource instanceof Bundle _inputResource && (_inputResource.getType() == Bundle.BundleType.SEARCHSET)) { List bundleResources = new ArrayList<>(); for (Bundle.BundleEntryComponent entry : ((Bundle) inputResource).getEntry()) { - if (entry.getResource().fhirType().equals("Bundle")) { - bundleResources.add(entry.getResource()); - } + bundleResources.add(entry.getResource()); } - if (bundleResources.stream() - .allMatch(resource -> ((Bundle) resource).getResourceType() == ResourceType.Bundle)) { - return bundleResources; - } + return bundleResources; } return Arrays.asList(inputResource); diff --git a/src/test/resources/results/searchSet.json b/src/test/resources/results/searchSet.json index 2e53ede9..4b285f30 100644 --- a/src/test/resources/results/searchSet.json +++ b/src/test/resources/results/searchSet.json @@ -2391,6 +2391,44 @@ "Bundle.entry[4].resource/*Organization/154dcc4a-0006-4272-9758-9dcb8d95ce8b*/", "Line[1] Col[3089]" ] + }, + { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-line", + "valueInteger": 1 + }, + { + "url": "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-col", + "valueInteger": 496 + } + ], + "severity": "warning", + "code": "processing", + "diagnostics": "Constraint failed: dom-6: 'A resource should have narrative for robust management' (defined in http://hl7.org/fhir/StructureDefinition/DomainResource) (Best Practice Recommendation)", + "location": [ + "OperationOutcome", + "Line[1] Col[496]" + ] + }, + { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-line", + "valueInteger": 1 + }, + { + "url": "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-col", + "valueInteger": 496 + } + ], + "severity": "warning", + "code": "processing", + "diagnostics": "Constraint failed: dom-6: 'A resource should have narrative for robust management' (defined in http://hl7.org/fhir/StructureDefinition/DomainResource) (Best Practice Recommendation)", + "location": [ + "OperationOutcome", + "Line[1] Col[496]" + ] } ] }