-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from sarnold/yagrep
add support for simple control ID analysis
- Loading branch information
Showing
23 changed files
with
1,582 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
importlib-metadata; python_version < '3.8' | ||
importlib-resources; python_version < '3.10' | ||
dpath | ||
munch | ||
nested-lookup | ||
PyYAML | ||
ruamel.yaml | ||
xmltodict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
Simple ID string counter. | ||
""" | ||
|
||
import os | ||
import sys | ||
import typing | ||
from collections import Counter | ||
from pathlib import Path | ||
|
||
from ymltoxml.utils import get_profile_sets | ||
|
||
id_count: typing.Counter[str] = Counter() | ||
FILE = os.getenv('ID_FILE', default='tests/data/PRIVACY-ids.txt') | ||
DEBUG = os.getenv('DEBUG', default=None) | ||
SELFTEST = os.getenv('SELFTEST', default=None) | ||
|
||
if not Path(FILE).exists(): | ||
print(f'Input file {FILE} not found!') | ||
sys.exit(1) | ||
|
||
input_ids = list(Path(FILE).read_text(encoding='utf-8').splitlines()) | ||
in_set = set(input_ids) | ||
|
||
print(f"Input control IDs -> {len(in_set)}") | ||
if DEBUG: | ||
print(sorted(in_set)) | ||
if SELFTEST: | ||
id_sets, id_names = get_profile_sets('tests/data') | ||
else: | ||
id_sets, id_names = get_profile_sets('800-53-control-ids/nist') | ||
|
||
for id_set, ptype in zip(id_sets, id_names): | ||
print(f"\n{ptype} profile control IDs -> {len(id_set)}") | ||
|
||
print(f"Input set is in {ptype} set: {id_set > in_set}") | ||
common_set = sorted(id_set & in_set) | ||
print(f"Num input controls in {ptype} set -> {len(common_set)}") | ||
not_in_set = sorted(in_set - id_set) | ||
print(f"Num input controls not in {ptype} set -> {len(not_in_set)}") | ||
if DEBUG: | ||
print(f"Input controls not in {ptype} set: {not_in_set}") | ||
|
||
print(f"\n{id_names[2]} set is in {id_names[0]} set: {id_sets[0] > id_sets[2]}") | ||
print(f"{id_names[2]} set is in {id_names[1]} set: {id_sets[1] > id_sets[2]}") | ||
print(f"{id_names[1]} set is in {id_names[0]} set: {id_sets[0] > id_sets[1]}") | ||
print(f"{id_names[3]} set is in {id_names[0]} set: {id_sets[0] > id_sets[3]}") | ||
|
||
if DEBUG: | ||
not_in_high = sorted(in_set - id_sets[0]) | ||
print("\nInput controls not in HIGH set\n") | ||
for ctl_id in not_in_high: | ||
print(ctl_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
"""Console tools for YAML/XML processing with config files in YAML.""" | ||
|
||
__description__ = "Console tools for YAML/XML conversion and sorting." | ||
|
||
__all__ = ["__description__"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# comments should be preserved | ||
file_encoding: 'utf-8' | ||
default_yml_ext: '.yaml' | ||
default_separator: '/' | ||
output_format: 'json' | ||
preserve_quotes: true | ||
process_comments: false | ||
mapping: 4 | ||
sequence: 6 | ||
offset: 4 |
Oops, something went wrong.