67 lines
1.7 KiB
Python
67 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Build the 2026 Nessus remediation tracker workbook."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from openpyxl import load_workbook
|
|
|
|
from build_tracker_workbook import MAX_TEMPLATE_ROWS
|
|
from build_tracker_workbook import build_remediations_sheet
|
|
from build_tracker_workbook import build_template_sheet
|
|
|
|
OLD_TRACKER_FILE = Path("OLD_Tracker.xlsx")
|
|
OUTPUT_FILE = Path("2026_Nessus_Remediation_Tracker.xlsx")
|
|
MONTH_SHEETS = [
|
|
"January",
|
|
"February",
|
|
"March",
|
|
"April",
|
|
"May",
|
|
"June",
|
|
"July",
|
|
"August",
|
|
"September",
|
|
"October",
|
|
"November",
|
|
"December",
|
|
]
|
|
|
|
|
|
def main() -> None:
|
|
if not OLD_TRACKER_FILE.exists():
|
|
raise FileNotFoundError(f"Missing required input file: {OLD_TRACKER_FILE}")
|
|
|
|
wb = load_workbook(OLD_TRACKER_FILE)
|
|
if "Intro" not in wb.sheetnames:
|
|
raise ValueError(f"Sheet 'Intro' not found in {OLD_TRACKER_FILE}")
|
|
|
|
for sheet_name in list(wb.sheetnames):
|
|
if sheet_name != "Intro":
|
|
wb.remove(wb[sheet_name])
|
|
|
|
scratch = wb.create_sheet("Scratch")
|
|
wb.active = wb.index(scratch)
|
|
build_remediations_sheet(wb)
|
|
build_template_sheet(wb, MAX_TEMPLATE_ROWS)
|
|
|
|
template_ws = wb["Template"]
|
|
template_ws.freeze_panes = "A2"
|
|
for month in MONTH_SHEETS:
|
|
month_ws = wb.copy_worksheet(template_ws)
|
|
month_ws.title = month
|
|
month_ws.freeze_panes = "A2"
|
|
|
|
ordered_sheets = ["Intro", "Remediations", "Template", *MONTH_SHEETS]
|
|
wb._sheets = [wb[name] for name in ordered_sheets]
|
|
|
|
temp_output = OUTPUT_FILE.with_suffix(".tmp.xlsx")
|
|
wb.save(temp_output)
|
|
temp_output.replace(OUTPUT_FILE)
|
|
print(f"Wrote {OUTPUT_FILE}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|