Skip to content

openscap: also importing description and rationale #12602

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

dd-alexander
Copy link

@dd-alexander dd-alexander commented Jun 13, 2025

Description

Importing more than just IdRef and Title of XCCDF Findings.

before
image

after
image

notes

results in the OpenSCAP XCCDF result.xml contain <code> and <pre> boxes for code. html2text seem to not be able to convert those boxes to proper markup for DefunctDojo. Has anybody an idea to somehow improve the style for descriptions?

example description of the result.xml (yes indention is that bad in the original file):

...
          <description xmlns:xhtml="http://www.w3.org/1999/xhtml" xml:lang="en-US">Disallow SSH login with empty passwords.
The default SSH configuration disables logins with empty passwords. The appropriate
configuration is used if no value is set for <html:code xmlns:html="http://www.w3.org/1999/xhtml">PermitEmptyPasswords</html:code>.
<html:br xmlns:html="http://www.w3.org/1999/xhtml"/>
To explicitly disallow SSH login from accounts with empty passwords,
add or correct the following line in


<html:code xmlns:html="http://www.w3.org/1999/xhtml">/etc/ssh/sshd_config.d/00-complianceascode-hardening.conf</html:code>:

<html:br xmlns:html="http://www.w3.org/1999/xhtml"/>
        <html:pre xmlns:html="http://www.w3.org/1999/xhtml">PermitEmptyPasswords no</html:pre>
Any accounts with empty passwords should be disabled immediately, and PAM configuration
should prevent users from being able to assign themselves empty passwords.</description>
...

Test results

No unit tests, but checked functionality on running DefectDojo instance.

Checklist

This checklist is for your information.

  • Make sure to rebase your PR against the very latest dev.
  • Features/Changes should be submitted against the dev.
  • Bugfixes should be submitted against the bugfix branch.
  • Give a meaningful name to your PR, as it may end up being used in the release notes.
  • Your code is flake8 compliant.
  • Your code is python 3.11 compliant.
  • If this is a new feature and not a bug fix, you've included the proper documentation in the docs at https://github.com/DefectDojo/django-DefectDojo/tree/dev/docs as part of this PR.
  • Model changes must include the necessary migrations in the dojo/db_migrations folder.
  • Add applicable tests to the unit tests.
  • Add the proper label to categorize your PR.

Copy link

DryRun Security

No security concerns detected in this pull request.


All finding details can be found in the DryRun Security Dashboard.

Copy link
Member

@valentijnscholten valentijnscholten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, some remarks:

  • Can you add/update the unit tests and sample to contain this rationale and description items?
  • Can you look at if it's possible to have a hash code field configuration for this parser? By default it uses ['title', 'cwe', 'line', 'file_path', 'description']. So if the description changes the upgrade notes should contain instructions for users to recalculate the hash_codes.

@dd-alexander
Copy link
Author

Thank you for the PR, some remarks:

* Can you add/update the unit tests and sample to contain this rationale and description items?

* Can you look at if it's possible to have a hash code field configuration for this parser? By default it uses ['title', 'cwe', 'line', 'file_path', 'description']. So if the description changes the upgrade notes should contain instructions for users to recalculate the hash_codes.
  • Where would be the place to add those tests? im not really familar with the dojo codebase and in the various tests folders i only could find dojo-releated and not tool/plugin related tests.
  • Im not quite sure what you mean with hash-code-field, could you please point me to a tool/plugin that has this already implemented?

@dd-alexander dd-alexander force-pushed the dd_openscap_descriptions branch from a3142a5 to 837ec63 Compare June 16, 2025 06:38
@dd-alexander dd-alexander force-pushed the dd_openscap_descriptions branch from 837ec63 to c34bc22 Compare June 16, 2025 08:05
@valentijnscholten
Copy link
Member

Could you look at https://github.com/DefectDojo/django-DefectDojo/blob/master/unittests/tools/test_openscap_parser.py and

# ------------------------------------
. The hash code configuration is used to calculate a unique id for each finding and use that for deduplication and reimport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants