Skip to content

Commit

Permalink
Revert "Add scripts to Update SRG"
Browse files Browse the repository at this point in the history
This reverts commit 6624b4c.
  • Loading branch information
Mab879 committed Feb 28, 2024
1 parent 6624b4c commit 08c0c6e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 101 deletions.
1 change: 1 addition & 0 deletions utils/build_stig_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def parse_args() -> argparse.Namespace:
help="Reference system to check for, defaults to stigid")
parser.add_argument('-s', '--split', action='store_true',
help='Splits the each ID into its own file.')

args = parser.parse_args()
check_output(args.output)
return args
Expand Down
23 changes: 8 additions & 15 deletions utils/import_srg_spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ def create_output(rule_dir: str) -> str:
def replace_yaml_key(key: str, replacement: str, rule_dir: dict) -> None:
path_dir = rule_dir['dir']
path = os.path.join(path_dir, 'rule.yml')
replace_yaml_key_file(key, replacement, path)


def replace_yaml_key_file(key: str, replacement: str, path: str) -> None:
lines = read_file_list(path)
section_ranges = find_section_lines(lines, key)
lines = get_yaml_contents(rule_dir)
section_ranges = find_section_lines(lines.contents, key)
replacement_line = f"{key}: {replacement}"
if section_ranges:
result = lines.contents[:section_ranges[0].start]
Expand All @@ -69,7 +65,7 @@ def replace_yaml_key_file(key: str, replacement: str, path: str) -> None:
for line in lines.contents[end_line:]:
result = (*result, line)
else:
result = lines
result = lines.contents
result = (*result, replacement_line)

with open(path, 'w') as f:
Expand All @@ -89,7 +85,9 @@ def write_output(path: str, result: tuple) -> None:
f.write('\n')


def write_yaml_section_replacement(path: str, replacement: str, section: str) -> None:
def replace_yaml_section(section: str, replacement: str, rule_dir: dict) -> None:
path = create_output(rule_dir['dir'])

lines = read_file_list(path)
replacement = replacement.replace('<', '&lt').replace('>', '&gt')
section_ranges = find_section_lines(lines, section)
Expand All @@ -109,11 +107,6 @@ def write_yaml_section_replacement(path: str, replacement: str, section: str) ->
write_output(path, result)


def replace_yaml_section(section: str, replacement: str, rule_dir: dict) -> None:
path = create_output(rule_dir['dir'])
write_yaml_section_replacement(path, replacement, section)


def add_replacement_to_result(replacement, result):
for line in replacement.split("\n"):
if line != "":
Expand All @@ -136,14 +129,14 @@ def get_common_set(changed_sheet: Worksheet, current_sheet: Worksheet, end_row:
return common_set


def update_severity(changed, current, rule_dir_json) -> None:
def update_severity(changed, current, rule_dir_json):
if changed.Severity != current.Severity and changed.Severity is not None and \
current.Severity is not None:
cac_severity = get_cac_status(changed.Severity)
replace_yaml_key('severity', cac_severity, rule_dir_json)


def update_row(changed: str, current: str, rule_dir_json: dict, section: str) -> None:
def update_row(changed: str, current: str, rule_dir_json: dict, section: str):
if changed != current and changed:
replace_yaml_section(section, changed, rule_dir_json)

Expand Down
86 changes: 0 additions & 86 deletions utils/update_stig_control.py

This file was deleted.

0 comments on commit 08c0c6e

Please sign in to comment.