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

Import SRG content for RHEL9 #9574

Merged
merged 17 commits into from
Oct 11, 2022
Merged

Conversation

Mab879
Copy link
Member

@Mab879 Mab879 commented Sep 27, 2022

Description:

Import SRG content for RHEL9 STIG.

Rationale:

Sync content to the repo.

@Mab879 Mab879 added this to the 0.1.65 milestone Sep 27, 2022
@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Comment on lines +4 to +7
vuldiscussion: |-
Service configuration files enable or disable features of their respective services that if configured incorrectly
can lead to insecure and vulnerable configurations. Therefore, service configuration files should be owned by the
correct group to prevent unauthorized changes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

For some reason the VulDiscussion column is empty in the generated HTML. Can you investigate this problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be fixed now.

@@ -0,0 +1,45 @@
srg_requirement: |-
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does the content of the policy file appear in the resolved rule yaml when I build a different product than RHEL 9, for example RHEL 8, for example I can see this text in policy_specific_content key build/rhel8/rules/service_kdump_disabled.yml. Is that expected behavior or not?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is. Since the content is in the shared.yml file all products will get the content. Products can override this by adding their own files. For example, rhel8.yml. Currently, family files (e.g., rhel.yml) are not supported.

@jan-cerny
Copy link
Collaborator

Hi @Mab879 , we should make sure that the imported data are the same data as in the DISA spreadsheet. We need to do it in an automated way because it's a large amount of data that isn't possible to be reviewed. So I think we need to write some simple test script. We can leverage our script that can create the SRG export spreadsheet. We can then compare the spreadsheet created from the project data with the original spreadsheet. For example, we can convert both of them to CSVs and run some sore of diff on these CSVs. What do you think? Is it feasible to write a test like that?

@Mab879
Copy link
Member Author

Mab879 commented Oct 3, 2022

Hi @Mab879 , we should make sure that the imported data are the same data as in the DISA spreadsheet. We need to do it in an automated way because it's a large amount of data that isn't possible to be reviewed. So I think we need to write some simple test script. We can leverage our script that can create the SRG export spreadsheet. We can then compare the spreadsheet created from the project data with the original spreadsheet. For example, we can convert both of them to CSVs and run some sore of diff on these CSVs. What do you think? Is it feasible to write a test like that?

It is! See the new utils/srg_diff.py script.

@Mab879
Copy link
Member Author

Mab879 commented Oct 3, 2022

There is still some more tweaking to be done on the script. I will get that pushed tomorrow.

In some cases env_yaml can be `None`, don't assume it always
be defined. This commit adds some guarding to prevent errors
around working with `None`.

Also adds a test case for this as well.
This occurs when loading from rendered YAML files.
This also cleaned up import_srg_spreadsheet script as well.
@Mab879 Mab879 force-pushed the psc_import branch 5 times, most recently from 10c7152 to a8d31ce Compare October 4, 2022 21:07
@Mab879
Copy link
Member Author

Mab879 commented Oct 4, 2022

This is ready for review, the last Code Climate issue is existing code, and I don't feel the need to change it.

@Mab879
Copy link
Member Author

Mab879 commented Oct 5, 2022

Attached is an example of the output, diff.html.txt

@Mab879 Mab879 added the Infrastructure Our content build system label Oct 5, 2022
Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

The utils/srg_diff.py tool is amazing and very helpful. I generated the HTML diff. Are all the differences that are shown in my HTML diff expected? Some of them seem that there was some change meanwhile. See comments below.

The "tmux" package allows for a session lock to be implemented and configured.

checktext: |-
Verify that {{{ full_name }}} has the tmux package installed with the following command:$ sudo dnf list --installed tmuxtmux.x86_64 3.2a-4.el9If the tmux package is not installed, this is a finding.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing newlines

The DoD has mandated the use of the Common Access Card (CAC) to support identity management and personal authentication for systems covered under Homeland Security Presidential Directive (HSPD) 12, as well as making the CAC a primary component of layered protection for national security systems.

checktext: |-
Verify that {{{ full_name }}} has the opensc package installed with the following command:$ sudo dnf list --installed openscopensc.x86_64 0.22.0-2.el9If the opensc package is not installed, this is a finding.
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing newlines

Add or edit the following line in a system configuration file in the "/etc/sysctl.d/" directory:

kernel.randomize_va_space = 2

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the The system configuration files need to be reloaded for the changes to take effect. missing here?


fs.protected_symlinks = 1

Load settings from all system configuration files with the following command:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the The system configuration files need to be reloaded for the changes to take effect. removed from hrer?

Copy link
Member Author

Choose a reason for hiding this comment

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

It appears to be a style change from the external reviewer.

for the rsyslog daemon, which enables secure remote logging.

checktext: |-
Verify that {{{ full_name }}} has the rsyslog-gnutls package installed with the following command:$ sudo dnf list --installed rsyslog-gnutlsrsyslog-gnutls.x86_64 8.2102.0-101.el9_0.1If the rsyslog-gnutls package is not installed, this is a finding.
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing newlines inside


Example:

```basj
Copy link
Collaborator

Choose a reason for hiding this comment

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

bash

@jan-cerny jan-cerny self-assigned this Oct 5, 2022
@Mab879
Copy link
Member Author

Mab879 commented Oct 5, 2022

The utils/srg_diff.py tool is amazing and very helpful. I generated the HTML diff. Are all the differences that are shown in my HTML diff expected? Some of them seem that there was some change meanwhile. See comments below.

There are going some deltas, the plan is to fix those up in a follow-up PR.

@codeclimate
Copy link

codeclimate bot commented Oct 5, 2022

Code Climate has analyzed commit b1d853f and detected 3 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Style 1

The test coverage on the diff in this pull request is 83.3% (50% is the threshold).

This pull request will bring the total coverage in the repository to 40.9% (0.1% change).

View more on Code Climate.

@jan-cerny
Copy link
Collaborator

Hi @Mab879, I have discussed this with @vojtapolasek and I have some questions.

Can you explain what is the meaning of the "Missing in DISA" and "Missing in CaC sections in the HTML report? I think that "Missing in DISA" is a list of rues in our STIG profile that don't have their counterpart in the DISA spreadsheet. But "Missing in CaC" contains a list of rules that exist in our project, so I'm confused. What is actually listed there? And how should I react as a reviewer when I see these lists are non-empty?

There are going some deltas, the plan is to fix those up in a follow-up PR.

What would be the reason of fixing the differences in follow up PRs? Is it because the fixes will be complex? In general, I would prefer having the delta as minimal as possible before merging and fix everything in this PR.

Also, we noticed that there are basically 3 categories of diffs in the HTML diff:

  1. whitespace differences
  2. typos
  3. serious diffs like in partition_for_var_tmp

What would be the action plan for addressing diffs of each of these 3 categories?

Side note: It seems that the HTML output isn't accessible. Do you know whether it's possible to generate a text diff instead? Or configure the library to generate some different HTML tags? This is not a blocker issue, but if the script would be used more frequently, it would be nice to make it accessible later.

@vojtapolasek
Copy link
Collaborator

Accessibility note: would it be possible to use and tags instead / together with colors to mark diffs? In this way, it would make review much easier for screenreader users.

@Mab879
Copy link
Member Author

Mab879 commented Oct 6, 2022

Hi @Mab879, I have discussed this with @vojtapolasek and I have some questions.

Can you explain what is the meaning of the "Missing in DISA" and "Missing in CaC sections in the HTML report? I think that "Missing in DISA" is a list of rues in our STIG profile that don't have their counterpart in the DISA spreadsheet. But "Missing in CaC" contains a list of rules that exist in our project, so I'm confused. What is actually listed there? And how should I react as a reviewer when I see these lists are non-empty?

Rules that are in the spreadsheet and not in the control file will be Missing in CaC.
Rules that are in the control file and not in the spreadsheet will be ender Missing in DISA.
For this review, that is expected, as dropped rules from the STIG are still in the spreadsheet.
The plan is to get this better synced in an upcoming PR.

There are going some deltas, the plan is to fix those up in a follow-up PR.

What would be the reason of fixing the differences in follow-up PRs? Is it because the fixes will be complex? In general, I would prefer having the delta as minimal as possible before merging and fix everything in this PR.

So we have another round of feedback that is happening right now.
Spending time getting this perfect doesn't seem like the best of use of time.

Also, we noticed that there are basically 3 categories of diffs in the HTML diff:

1. whitespace differences

2. typos

3. serious diffs like in partition_for_var_tmp

What would be the action plan for addressing diffs of each of these 3 categories?

  1. The whitespace differences are in the spreadsheet there isn't much we can do about it.
  2. typos in which direction? Remember that the left is in the spreadsheet from DISA. If the right is correct, it should be ignored.
  3. Some serious changes are fixing issues from the spreadsheet, again if the right is correct, it should be ignored.

Side note: It seems that the HTML output isn't accessible. Do you know whether it's possible to generate a text diff instead? Or configure the library to generate some different HTML tags? This is not a blocker issue, but if the script would be used more frequently, it would be nice to make it accessible later.

Accessibility is not going to be easy. I will have to change what library I use to create the diffs. Currently, I'm just using the Python standard library.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

We have discussed this with @ggbecker .

The main thing that I was missing was that in future there will be another import of the DISA spreadsheet data and after that import we can easily git diff to analyse differences between data that we have in our repo and new version of the spreadsheet. That will greatly help us with our STIG alignement process.

The diff created by the srg_diff.py serves to verify that the data is imported correctly. In theory, there should be no diff between the imported data and exported data. However, the spreadsheet changes and I don't have the exact version that was used for the import available at hand. Therefore, there is some diff.

However, this diff is small. As we will do another import of the data in future we will slowly converge to no diff produced by srg_diff.py.

The expected next import(s) of data also means why we don't insist on making the diff empty - insinsiting on it would make sense only if we are given final version of the spreadsheet that will never change.

@jan-cerny jan-cerny merged commit 638fee7 into ComplianceAsCode:master Oct 11, 2022
@jan-cerny jan-cerny added the STIG STIG Benchmark related. label Oct 11, 2022
@Mab879 Mab879 deleted the psc_import branch October 14, 2022 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Our content build system STIG STIG Benchmark related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants