Skip to content

Commit

Permalink
hide submission validation behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sbelsk committed Sep 10, 2024
1 parent 581791b commit ed8459c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ DB_PASSWORD=secret
# to some value other than 'sync'.
#REMOTE_WORKERS=false

# Whether or not submission XML files are validated before being processed.
# Enabling this setting will trigger a scan through XML files uploaded in
# each submission in order to preemptively reject malformed files.
#VALIDATE_XML_SUBMISSIONS=true

# Should we show the most recent submission time for a project or subproject?
# Disabling this feature can improve rendering performance of index.php
# for projects with lots of subproject builds.
Expand Down
8 changes: 4 additions & 4 deletions app/cdash/include/ctestparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ function ctest_parse($filehandle, string $filename, $projectid, $expected_md5 =
$file = $xml_info['xml_type'];
$schema_file = $xml_info['xml_schema'];

// Ensure the XML file is valid if the XML type has a schema defined
if (isset($schema_file)) {
// If validation is enabled and if this file has a corresponding schema, validate it
if (((bool) config('cdash.validate_xml_submissions')) === true && isset($schema_file)) {
try {
SubmissionUtils::validate_xml($filename, $schema_file);
} catch (CDashXMLValidationException $e) {
foreach ($e->getDecodedMessage() as $error) {
Log::error($error);
Log::error("Validating $filename: ".$error);
}
return false;
abort(400, "Xml validation failed: rejected file $filename");
}
}

Expand Down
1 change: 1 addition & 0 deletions config/cdash.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
'show_last_submission' => env('SHOW_LAST_SUBMISSION', true),
'slow_page_time' => env('SLOW_PAGE_TIME', 10),
'token_duration' => env('TOKEN_DURATION', 15811200),
'validate_xml_submissions' => env('VALIDATE_XML_SUBMISSIONS', false),
// Specify whether users are allowed to create "full access" authentication tokens
'allow_full_access_tokens' => env('ALLOW_FULL_ACCESS_TOKENS', true),
// Specify whether users are allowed to create "submit only" tokens which are valid for all projects
Expand Down
4 changes: 4 additions & 0 deletions docs/submissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ for both the CDash web service and the remote worker(s).
## Deferred submissions

CDash automatically detects when its database is unavailable and stores submissions received during this outage. When database access is restored, CDash will attempt to parse the submissions that were received during the outage. This behavior is controlled by the presence of the file named `DB_WAS_DOWN` in the storage directory.

## Submission files validation

CDash can be configured to validate submitted XML files before attempting to process them, in order to preemptively reject malformed files. If enabled, once a submission is moved out of the queue, its XML files will be scanned for valid syntax and validated against the [XML schemas](../app/Validators/Schemas/) CDash supports. To use this feature, set `VALIDATE_XML_SUBMISSIONS=true` in your `.env` file.

0 comments on commit ed8459c

Please sign in to comment.