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

Fix bug with file extension checks on products #1112

Merged
merged 7 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import gov.nasa.pds.tools.util.Utility;
import gov.nasa.pds.tools.util.VersionInfo;
import gov.nasa.pds.tools.util.XMLExtractor;
import gov.nasa.pds.tools.validate.ProblemContainer;
import gov.nasa.pds.tools.validate.ProblemDefinition;
import gov.nasa.pds.tools.validate.ProblemHandler;
import gov.nasa.pds.tools.validate.ProblemType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
import org.slf4j.LoggerFactory;
import gov.nasa.pds.tools.util.Utility;
import gov.nasa.pds.tools.util.XslURIResolver;
import gov.nasa.pds.tools.validate.ProblemDefinition;
import gov.nasa.pds.tools.validate.ProblemHandler;
import gov.nasa.pds.tools.validate.ProblemType;
import gov.nasa.pds.tools.validate.ValidationProblem;

/**
* A class that transforms Schematron files based on the isoSchematron stylesheet.
Expand All @@ -64,7 +61,7 @@ private Transformer buildIsoTransformer() throws TransformerConfigurationExcepti
TransformerFactory isoFactory = TransformerFactory.newInstance();
try {
isoFactory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true);
isoFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
//isoFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); see validate#1103
isoFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
} catch (TransformerConfigurationException e) {
throw new TransformerConfigurationException("Failed to configure TransformerFactory for secure processing", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ public synchronized Collection<String> getUnreferencedTargets() {
return unreferencedTargets;
}

@Override
public synchronized Collection<Identifier> getReferencedIdentifiers() {
return referencedIdentifiers;
}

@Override
public synchronized Collection<Identifier> getUnreferencedIdentifiers() {
List<Identifier> unreferencedIdentifiers = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public interface TargetRegistrar {
*
* @return a collection of referenced identifiers.
*/
Collection<Identifier> getReferencedIdentifiers();

/**
* Gets the location of where the given identifier is referenced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ public void collectionReferentialIntegrityRule() {
LOG.debug("collectionReferentialIntegrityRule:getTarget() {}, num collections {}",
getTarget(), collections.keySet().size());

// Check for collection(_.*)?\.(xml or lblx) file.
for (Map.Entry<String, ValidationTarget> collection : collections.entrySet()) {
if (!collection.getValue().getLocation().endsWith(getContext().getLabelExtension())) {
continue;
}

Target collectionTarget = new Target(collection.getValue().getUrl(), false);
try {
XMLExtractor extractor = new XMLExtractor(collectionTarget.getUrl());
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/features/3.6.x.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Feature: validate_integration_3_6
| testId | testName | testDir | messageCount | messageText | problemEnum | resourceDir | reportDir | commandArgs | refOutputValue |
# Validate#1028
| NASA-PDS/validate#1028 | "NASA-PDS/validate#1028 New SEED mime type" | "github1028" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github1028.json -s json --skip-context-validation -t {resourceDir}/github1028/xa.s16..shz.1976.070.0.xml --schema {resourceDir}/github1028/PDS4_PDS_1N00.xsd --schematron {resourceDir}/github1028/PDS4_PDS_1N00.sch" | "report_github1028.json" |
# Validate#1100
| NASA-PDS/validate#1100 | "NASA-PDS/validate#1100 Bad extension checking" | "github1100" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github1100.json -s json --skip-context-validation -R pds4.bundle -t {resourceDir}/github1100" | "report_github1100.json" |
# Validate#1008
| NASA-PDS/validate#1008 | "NASA-PDS/validate#1008 PDF on windows" | "github1008" | 1 | "1 errors expected" | "NON_PDFA_FILE" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github1008.json -s json --skip-context-validation -t {resourceDir}/github1008/example.xml" | "report_github1008.json" |
# Validate#992
Expand Down
13 changes: 7 additions & 6 deletions src/test/resources/features/pre.3.6.x.feature
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ Scenario Outline: <testId>
| NASA-PDS/validate#604 |"NASA-PDS/validate#604 Success Multiple Tables One File" | "github604" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github604.json -s json --skip-context-validation -t {resourceDir}/github604/video.xml" | "report_github604.json" |

# Validate#599
| NASA-PDS/validate#599 |"NASA-PDS/validate#599 Success No Override Schema/Schematron" | "github599" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github599_1.json -s json -t {resourceDir}/github599/AREA_Camelot_1radii.xml" | "report_github599_1.json" |
#|"NASA-PDS/validate#599 Failure Override Schema" | "github599" | 1 | "1 errors expected" | "SCHEMA_ERROR" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github599_2.json -s json -x {resourceDir}/github599/PDS4_PDS_1I00.xsd -t {resourceDir}/github599/AREA_Camelot_1radii.xml" | "report_github599_2.json" |
| NASA-PDS/validate#599 |"NASA-PDS/validate#599 Success No Override Schema/Schematron" | "github599" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github599_1.json -s json --skip-context-validation -t {resourceDir}/github599/AREA_Camelot_1radii.xml" | "report_github599_1.json" |
#|"NASA-PDS/validate#599 Failure Override Schema" | "github599" | 1 | "1 errors expected" | "SCHEMA_ERROR" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github599_2.json -s json --skip-context-validation -x {resourceDir}/github599/PDS4_PDS_1I00.xsd -t {resourceDir}/github599/AREA_Camelot_1radii.xml" | "report_github599_2.json" |
#|"NASA-PDS/validate#599 Failure Override Schematron" | "github599" | 1 | "1 errors expected" | "SCHEMA_ERROR" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github599_3.json -s json -S {resourceDir}/github599/PDS4_PDS_1I00.sch -t {resourceDir}/github599/AREA_Camelot_1radii.xml" | "report_github599_3.json" |
#|"NASA-PDS/validate#599 Failure Override Schema+Schematron" | "github599" | 1 | "1 errors expected" | "SCHEMA_ERROR" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github599_4.json -s json -S {resourceDir}/github599/PDS4_PDS_1I00.sch -x {resourceDir}/github599/PDS4_PDS_1I00.xsd -t {resourceDir}/github599/AREA_Camelot_1radii.xml" | "report_github599_4.json" |

Expand Down Expand Up @@ -214,8 +214,9 @@ Scenario Outline: <testId>
| NASA-PDS/validate#47-1 |"NASA-PDS/validate#47 1" | "github47" | 0 | "0 errors expected." | "CONTEXT_REFERENCE_NOT_FOUND" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github47_disable-valid.json -s json --disable-context-mismatch-warnings -R pds4.label --skip-content-validation --skip-context-validation {resourceDir}/github47/test_context_products.xml" | "report_github47_disable-valid.json" |
| NASA-PDS/validate#47-2 |"NASA-PDS/validate#47 2" | "github47" | 1 | "1 errors expected." | "CONTEXT_REFERENCE_NOT_FOUND" | "src/test/resources" | "target/test" | "-v1 --skip-content-validation -r {reportDir}/report_github47_enable-valid.json -s json --disable-context-mismatch-warnings -R pds4.label {resourceDir}/github47/test_context_products.xml" | "report_github47_enable-valid.json" |

| NASA-PDS/validate#62 |"NASA-PDS/validate#62 1" | "github62" | 4 | "4 info.label.context_ref_found info messages expected.\n" | "CONTEXT_REFERENCE_FOUND" | "src/test/resources" | "target/test" | "-v1 -r {reportDir}/report_github62_1.json -s json --no-data-check -t {resourceDir}/github62/ele_mom_tblChar.xml" | "report_github62_1.json" |
| NASA-PDS/validate#62-1 |"NASA-PDS/validate#62 2" | "github62" | 8 | "8 info/error messages expected.\n" | "CONTEXT_REFERENCE_FOUND,CONTEXT_REFERENCE_NOT_FOUND" | "src/test/resources" | "target/test" | "-v1 -r {reportDir}/report_github62_2.json -s json --no-data-check -t {resourceDir}/github62/spacecraft.orex_1.1.xml" | "report_github62_2.json" |
# FIXME: durning rework of cucumber, look at this again
#| NASA-PDS/validate#62 |"NASA-PDS/validate#62 1" | "github62" | 4 | "4 info.label.context_ref_found info messages expected.\n" | "CONTEXT_REFERENCE_FOUND" | "src/test/resources" | "target/test" | "-v1 -r {reportDir}/report_github62_1.json -s json --skip-content-validation -t {resourceDir}/github62/ele_mom_tblChar.xml" | "report_github62_1.json" |
| NASA-PDS/validate#62-1 |"NASA-PDS/validate#62 2" | "github62" | 8 | "8 info/error messages expected.\n" | "CONTEXT_REFERENCE_FOUND,CONTEXT_REFERENCE_NOT_FOUND" | "src/test/resources" | "target/test" | "-v1 -r {reportDir}/report_github62_2.json -s json --skip-content-validation -t {resourceDir}/github62/spacecraft.orex_1.1.xml" | "report_github62_2.json" |

# Move github278 before github71 as it causing issues
# By declaring the error type, should allow the zero length PDF file to go unnoticed.
Expand Down Expand Up @@ -273,7 +274,7 @@ Scenario Outline: <testId>

# https://github.com/NASA-PDS/validate/issues/298 validate misses double quotes within a delimited table

| NASA-PDS/validate#298 |"NASA-PDS/validate#298 VALID" | "github298" | 0 | "0 errors messages expected." | "totalErrors" | "src/test/resources" | "target/test" | "-R pds4.label -r {reportDir}/report_github298_label_valid.json -s json {resourceDir}/github298/valid/sentences.xml" | "report_github298_label_valid.json" |
| NASA-PDS/validate#298 |"NASA-PDS/validate#298 VALID" | "github298" | 0 | "0 errors messages expected." | "totalErrors" | "src/test/resources" | "target/test" | "--skip-context-validation -R pds4.label -r {reportDir}/report_github298_label_valid.json -s json {resourceDir}/github298/valid/sentences.xml" | "report_github298_label_valid.json" |
| NASA-PDS/validate#298-1 |"NASA-PDS/validate#298 INVALID" | "github298" | 43 | "43 errors expected for INVALID_FIELD_VALUE ." | "INVALID_FIELD_VALUE" | "src/test/resources" | "target/test" | "-R pds4.label -r {reportDir}/report_github298_label_invalid.json -s json {resourceDir}/github298/invalid/sentences.xml" | "report_github298_label_invalid.json" |

# https://github.com/NASA-PDS/validate/issues/188 As a user, I want to validate a bundle that uses multiple versions of the Information Model / Discipline LDDs
Expand Down Expand Up @@ -438,7 +439,7 @@ Scenario Outline: <testId>

# https://github.com/NASA-PDS/validate/issues/349 validate allows absolute path in directory_path_name but shouldn't

| NASA-PDS/validate#349 |"NASA-PDS/validate#349 VALID" | "github349" | 0 | "0 error messages expected" | "totalErrors" | "src/test/resources" | "target/test" | "-R pds4.label -r {reportDir}/report_github349_label_valid.json -s json -t {resourceDir}/github349/valid/datasetgood.xml" | "report_github349_label_valid.json" |
| NASA-PDS/validate#349 |"NASA-PDS/validate#349 VALID" | "github349" | 0 | "0 error messages expected" | "totalErrors" | "src/test/resources" | "target/test" | "--skip-context-validation -R pds4.label -r {reportDir}/report_github349_label_valid.json -s json -t {resourceDir}/github349/valid/datasetgood.xml" | "report_github349_label_valid.json" |
| NASA-PDS/validate#349-1 |"NASA-PDS/validate#349 INVALID" | "github349" | 1 | "1 error messages expected" | "UNALLOWED_DIRECTORY_NAME" | "src/test/resources" | "target/test" | "-R pds4.label -r {reportDir}/report_github349_label_invalid.json -s json -t {resourceDir}/github349/invalid/datasetbad.xml" | "report_github349_label_invalid.json" |

# https://github.com/NASA-PDS/validate/issues/419 validate 2.2.0-SNAPSHOT warns about a pretty benign bundle + readme.txt
Expand Down
90 changes: 90 additions & 0 deletions src/test/resources/github1100/bundle_suda.XML
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0"?>
<?xml-model
href="https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1J00.sch"
schematypens="http://purl.oclc.org/dsdl/schematron"
?>
<Product_Bundle
xmlns="http://pds.nasa.gov/pds4/pds/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pds.nasa.gov/pds4/pds/v1
https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1J00.xsd">
<Identification_Area>
<logical_identifier>urn:nasa:pds:clipper.sud</logical_identifier>
<version_id>1.0</version_id>
<title>Europa Clipper SUDA Bundle</title>
<information_model_version>1.19.0.0</information_model_version>
<product_class>Product_Bundle</product_class>
<Citation_Information>
<author_list>Kempf, Sascha; Curtin, Alexandra; Polson, Shawn</author_list>
<publication_year>2024</publication_year>
<doi>10.26033/xaky-md22</doi>
<description>This bundle collects all the operational data products produced by the SUDA instrument onboard the Europa Clipper spacecraft.</description>
</Citation_Information>
<Modification_History>
<Modification_Detail>
<modification_date>2024-12-03</modification_date>
<version_id>1.0</version_id>
<description>Initial release.</description>
</Modification_Detail>
</Modification_History>
</Identification_Area>
<Context_Area>
<Time_Coordinates>
<start_date_time>2022-08-30T13:32:12.723000Z</start_date_time>
<stop_date_time>2022-08-30T16:48:38.364000Z</stop_date_time>
</Time_Coordinates>
<Primary_Result_Summary>
<purpose>Science</purpose>
<processing_level>Raw</processing_level>
<processing_level>Partially Processed</processing_level>
<Science_Facets>
<domain>Surface</domain>
<discipline_name>Small Bodies</discipline_name>
<facet1>Dust Study</facet1>
</Science_Facets>
</Primary_Result_Summary>
<Investigation_Area>
<name>Europa Clipper Mission</name>
<type>Mission</type>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:investigation:mission.clipper</lid_reference>
<reference_type>bundle_to_investigation</reference_type>
</Internal_Reference>
</Investigation_Area>
<Observing_System>
<name>Europa Clipper</name>
<Observing_System_Component>
<name>Europa Clipper Spacecraft</name>
<type>Host</type>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:instrument_host:spacecraft.clipper</lid_reference>
<reference_type>is_instrument_host</reference_type>
</Internal_Reference>
</Observing_System_Component>
<Observing_System_Component>
<name>SUrface Dust Analyzer (SUDA)</name>
<type>Instrument</type>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:instrument:clipper.sud</lid_reference>
<reference_type>is_instrument</reference_type>
</Internal_Reference>
</Observing_System_Component>
</Observing_System>
<Target_Identification>
<name>DUST</name>
<type>Dust</type>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:target:dust.dust</lid_reference>
<reference_type>bundle_to_target</reference_type>
</Internal_Reference>
</Target_Identification>
</Context_Area>
<Bundle>
<bundle_type>Archive</bundle_type>
</Bundle>
<Bundle_Member_Entry>
<lidvid_reference>urn:nasa:pds:clipper.sud:data_sci_calibrated::1.0</lidvid_reference>
<member_status>Primary</member_status>
<reference_type>bundle_has_data_collection</reference_type>
</Bundle_Member_Entry>
</Product_Bundle>
Loading
Loading