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

BUG: Importing SCAP for Windows Server 2016/2019 error #275

Closed
2 of 4 tasks
18gold opened this issue Apr 28, 2021 · 7 comments · Fixed by #290
Closed
2 of 4 tasks

BUG: Importing SCAP for Windows Server 2016/2019 error #275

18gold opened this issue Apr 28, 2021 · 7 comments · Fixed by #290
Labels
bug Something isn't working

Comments

@18gold
Copy link

18gold commented Apr 28, 2021

Bug Location

I found a bug in the:

  • API
  • UI
  • Elsewhere (Please specify)

Bug Description:
Importing SCAP (XCCDF) results for Windows Server 2016/2019 results in:
Cannot read property 'check-content-ref' of undefined

  • I have checked to see if there is already an existing issue that describes this bug.

To Reproduce
Steps to reproduce the behavior:

  1. Open a collection
  2. Click on 'Manage'
  3. From 'Assets' click 'Import CKL or SCAP...'
  4. Browse to XCCDF results for Windows 2016/2019
  5. Error

Expected behavior
Expected to import SCAP results

Actual behavior
Error and no results are impoted

Environment or Configuration:

  • Docker Container
  • Browser: Chrome
@18gold 18gold added the bug Something isn't working label Apr 28, 2021
@csmig
Copy link
Member

csmig commented Apr 28, 2021

Curious. Which SCAP engine produced these results? The XCCDF standard does not require that property, but the SCC tool has always included it, at least up through this winter. SCC is the tool I've written our parser against.

If possible, please look into the XCCDF content for instances of the <cdf:check> element descended from <cdf:TestResult><cdf:rule-result> there should be hundreds of them. The parser is expecting a <xccdf:check-content-ref> child element to be present. An example:

<cdf:check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
    <xccdf:check-content-ref name="oval:mil.disa.stig.windows:def:2137" href="U_MS_Windows_Server_2019_V2R1_STIG_SCAP_1-2_Benchmark-oval.xml" />
</cdf:check>

It looks like the parser did not expect either of these elements to be missing. I can fix that, but I'd like to understand the toolchain that produced an XCCDF without one or more of these elements.

Thank you.

@csmig
Copy link
Member

csmig commented Apr 28, 2021

@18gold Also, please provide the version of STIG Manager you're using. The latest release actually regressed a bit in supporting XCCDF so the fact you got as far as you did suggests you might not be using 1.0.0-beta.30?

I've been refactoring the parsers to cope with the nuances of CKL processing and I know that XCCDF support has regressed. I intend to deal with that the next day or so. There are some challenges matching SCAP to Manual STIGs because very often the Manual benchmarkId differs from the Benchmark benchmarkId. We need to maintain a mapping table, DISA does make this challenging.

@18gold
Copy link
Author

18gold commented Apr 29, 2021

@csmig
STIG Manager Version: 1.0.0-beta.25
SCC Engine: 5.4

I looked into the XCCDF file and the formatting is a bit different than the supposedly expected element you suggested above. Could be causing the issue:

<cdf:check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
         <cdf:check-content-ref name="oval:mil.disa.stig.windows:def:1020" href="U_MS_Windows_Server_2016_V2R1_STIG_SCAP_1-2_Benchmark-oval.xml"></cdf:check-content-ref>
</cdf:check>

@csmig
Copy link
Member

csmig commented Apr 29, 2021

@18gold Thanks for the very helpful info. One more question -- do results from other Benchmarks import okay for you?

The error you got suggests at least one of the <cdf:rule-result> elements doesn't contain a child <cdf:check> and the parser can't handle that. I'll run the same Benchmark myself and see what I get but I need to modify the parser no matter what.

Annoyingly, this is really not a critical element for us to process, it is informational.

I'm rearchitecting SCAP handling this next week so this will work properly soon. Very much appreciate your report.

@cd-rite
Copy link
Collaborator

cd-rite commented Apr 29, 2021

Hi @18gold I can't recreate this issue with files generated by SCC 5.4, either in our latest STIGMan or the one you specified.

Are you having this issue with every XCCDF file you try to import, or just this one?

Can you verify that the XML element you provided was from within a <cdf:TestResult><cdf:rule-result> element? They are usually at the bottom of a results file.
All the check elements I have from that section include a "#scap_mil.disa.stig_comp_" prefix to the href= attribute.
This prefix difference wouldn't cause this problem, but it's the only difference I can identify at the moment.

@18gold
Copy link
Author

18gold commented Apr 29, 2021

@csmig yes, other Benchmarks import okay. Only Windows Server 2016/2019 are erroring.

@cd-rite We've only had issues specifically with Windows Server 2016/2019 Benchmarks. I'm linking the element from the last section of the file I last tried.

<cdf:check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
         <cdf:check-content-ref name="oval:mil.disa.stig.windows:def:1257" href="#scap_mil.disa.stig_comp_U_MS_Windows_Server_2016_V2R1_STIG_SCAP_1-2_Benchmark-oval.xml"></cdf:check-content-ref>
</cdf:check>

@csmig
Copy link
Member

csmig commented Apr 30, 2021

I would like to understand why there are missing elements, even if I can code around around them. Perhaps you could share a redacted version of your file?

To assist with that, here is an XSLT that redacts an XCCDF TestResult, removing any target identifying info and setting all results to pass.

redact-scc.xslt

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cdf="http://checklists.nist.gov/xccdf/1.2" xmlns:cpe2="http://cpe.mitre.org/language/2.0" exclude-result-prefixes="cpe2">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="comment()"/>
    <xsl:template match="cdf:profile"/>
    <xsl:template match="cdf:target-address"/>
    <xsl:template match="cdf:target-facts"/>
    <xsl:template match="cdf:target-id-ref"/>
    <xsl:template match="cdf:set-value"/>
    <xsl:template match="cdf:score">
        <cdf:score maximum="1" system="urn:xccdf:scoring:absolute">0</cdf:score>
    </xsl:template>
    <xsl:template match="cdf:identity">
        <cdf:identity privileged="true" authenticated="true">TEST</cdf:identity>
    </xsl:template>
    <xsl:template match="cdf:target">
        <cdf:target>TEST</cdf:target>
    </xsl:template>
    <xsl:template match="cdf:result">
        <cdf:result>pass</cdf:result>
    </xsl:template>
</xsl:stylesheet>

You'll need an XSLT processor, there are many choices depending on your platform. I used xmlstarlet to process the above, it is bundled with most Linux package distributions (for Ubuntu: apt install xmlstarlet) and there's a Windows download as well. But any other tool of your choice should be fine, too.

xmlstarlet tr redact-scc.xslt YOUR_SCC_RESULT_FILE > redacted_xccdf.xml

If possible, please run this transform against a file that is not importing and attach the redacted result. You'll need to change the extension to TXT. Thanks for any further assistance you can provide.

csmig added a commit to csmig/stig-manager that referenced this issue May 4, 2021
@csmig csmig closed this as completed in #290 May 4, 2021
csmig added a commit that referenced this issue May 4, 2021
* fix #275: handle rule-result without check

* asset properties and benchmarkId check
cd-rite added a commit to cd-rite/stig-manager that referenced this issue May 6, 2021
* feat: Collection export management (NUWCDIVNPT#169)

* fix: case-insensitive filename matching (NUWCDIVNPT#192)

* fix: Improved output when importing STIG XML (NUWCDIVNPT#192)

* doc: Show Export CKLs in screenshots

* chore: Bump release to 1.0.0-beta.22

* adjust path to docker readme (NUWCDIVNPT#196)

* doc: Added some documentation about new .ckl archive export feature. (NUWCDIVNPT#203)

* removed some todos

* stig archive export feature

* feat: name-match params and duplicate handling (NUWCDIVNPT#204)

* feat: case-sensitive collation for benchmarkId in MySQL (NUWCDIVNPT#206)

* Common tasks elaboration, other edits (NUWCDIVNPT#208)

* feat: progress bar styling (NUWCDIVNPT#209)

* feat: UI shows collectionId (NUWCDIVNPT#210)

* fix: remove hard-coded reference to schema (NUWCDIVNPT#211)

* chore: Bump release to 1.0.0-beta.23

* fix: reduce deadlock potential (NUWCDIVNPT#216)

* api links (NUWCDIVNPT#219)

* build(deps): bump y18n from 3.2.1 to 3.2.2 in /api/source

Bumps [y18n](https://github.com/yargs/y18n) from 3.2.1 to 3.2.2.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>

* doc: Added a little more about .ckl and data handling (NUWCDIVNPT#223)

* just rst changes

* sphinx generation

* fix: Exports on multiple reports (NUWCDIVNPT#224)

* Multiple fixes and features (NUWCDIVNPT#225)

* feat: return 401 when no token provided

* feat: home-widget-bwrap

* fix: collectionReview buttons

* fix: deadlock prevention status updates

* chore: Bump release to 1.0.0-beta.24

* fix: fetch STIG/SCAP if configured at bootstrap (NUWCDIVNPT#227)

Fixes NUWCDIVNPT#213

* Multiple fix and features (NUWCDIVNPT#228)

* feat: CKL parser retains empty comments
* feat: enable accept when selections include accept
* fix: review form button behaviors, etc. (NUWCDIVNPT#215)

* chore: remove unused oracledb dependency (NUWCDIVNPT#229)

* chore: remove unused oracledb dependency

* Remove unused require

* chore: Bump release to 1.0.0-beta.25

* feat: Manage Assets -> multi-delete (NUWCDIVNPT#232), columns (NUWCDIVNPT#236)

* fix: include promisfied confirm (NUWCDIVNPT#237)

* build(deps): bump urllib3 from 1.26.3 to 1.26.4 in /docs (NUWCDIVNPT#238)

Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.3 to 1.26.4.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@1.26.3...1.26.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* doc: updates regarding ckl -> stigman field mappings, clients folder when running from source (NUWCDIVNPT#241)

doc: updates regarding ckl -> stigman field mappings, clients folder when running from source

* feat: Tooltips for Review labels and headers (NUWCDIVNPT#240) (NUWCDIVNPT#242)

* feat: mercury-medium color is more blue (NUWCDIVNPT#243)

* fix: sticky bit for world-writable dirs created by npm (NUWCDIVNPT#245)

* chore: Bump release to 1.0.0-beta.26

* fix: increased length of asset name,ip,mac,fqdn and allow more nulls  (NUWCDIVNPT#251)

* added maxLength properties of 255 for ip, mac, asset name, and fqdn; added nullable:true for collection description properties

* removed vtype specification for ip address, as we will no longer be validating ip address field.

* Added migration file to alter varchar sizes for asset ip, mac, and name

* fix: batch import continues on error, refreshes grids (NUWCDIVNPT#252)

* feat: Ext.LoadMask looks for store.smMaskDelay (NUWCDIVNPT#254)

* chore: Bump release to 1.0.0-beta.27

* fix: log servicename if present (NUWCDIVNPT#198)

* fix: Attach => Assign STIG (NUWCDIVNPT#118)

* fix: response schema for /opt/configuration (NUWCDIVNPT#147)

* fix: create date is not ISO8601 UTC (NUWCDIVNPT#189)

* fix: handle property chains with hyphens (NUWCDIVNPT#257)

* fix: cast userId as char (NUWCDIVNPT#249)

* feat: format roles claim with bracket notation and optional chaining (NUWCDIVNPT#190)

* fix: SET NAME to utf8mb4 encoding (NUWCDIVNPT#262)

* fix: New/Delete => Assign/Unassign (NUWCDIVNPT#261)

* fix: New/Delete => Assign/Unassign (NUWCDIVNPT#118)

* dump docker logs on failure or cancellation

* fix: Filter members only on .xml extension  (NUWCDIVNPT#260)

* Removed attempts to filter STIG processing based on filename, since they do not seem to follow any reliable convention. Restricted error responses to just parser error message (removed stack trace portion so it does not show up in user's import log).

* added specific try/catch blocks around xml parsing

* fix NUWCDIVNPT#264: Display feedback for rejected reviews (NUWCDIVNPT#265)

* chore: Bump release to 1.0.0-beta.28

* fix NUWCDIVNPT#256: CKL site/instance handling; UI refactor (NUWCDIVNPT#268)

* chore: Bump release to 1.0.0-beta.29

* ironbank => development sign+image

* fix NUWCDIVNPT#266: sanitize exported filenames (NUWCDIVNPT#273)

* fix NUWCDIVNPT#270: ROLE element default value 'None' (NUWCDIVNPT#272)

* chore: Bump release to 1.0.0-beta.30

* fix NUWCDIVNPT#276: remove reference to database 'stigman'

* chore: remove obsolete docker dir (NUWCDIVNPT#278)

* Docs: Added default_group to prevent guid generation, removed doctrees, added a bit of info to Contributing doc. (NUWCDIVNPT#281)

* added default_group for images to stop guid generation
* removed doctrees
* added doctrees to .gitignore
*  added a couple paragraphs to contributing doc

* Endpoint updates (NUWCDIVNPT#284)

* feat: GET /assets metadata parameter

* feat: PUT /assets/{assetId}/stigs/{benchmarkId}

* tests match OpenAPI spec

* fix NUWCDIVNPT#145: Review vetting for all users (NUWCDIVNPT#285)

* fix NUWCDIVNPT#145: Review vetting for lvl1 users

* lvl1 cross-boundary tests, xccdf test file added, workflow updated to run new folder. Removed extra folders from Collection

* refactor adminStats, scc parser, tests, workflow

Co-authored-by: cd-rite <github-rite@notdoneyet.net>

* feat: Drag from Review History (NUWCDIVNPT#288)

* fix NUWCDIVNPT#275: handle rule-result without check (NUWCDIVNPT#290)

* fix NUWCDIVNPT#275: handle rule-result without check

* asset properties and benchmarkId check

* chore: Bump release to 1.0.0-beta.31

* checks for asset with no assigned STIGs, changed lvl1 checks to look for existing rule to which it does not have access (as opposed to non-existent rule)

* marked tests as continue-on-error so remaining tests would still run.

Co-authored-by: csmig <carlsmigielski@gmail.com>
Co-authored-by: csmig <33138761+csmig@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants