23 lines
922 B
Python
23 lines
922 B
Python
import re
|
|
|
|
ps = open(r'D:\VNPT-M\Tool\audit_tool\NEW\Update\audit_lhdsin\audit_check_script\audit_cis_windows.ps1', 'r', encoding='utf-8').read()
|
|
|
|
# Find variable definitions for CheckIdPrefix, LabelPrefix, Label
|
|
for m in re.finditer(r'\$(CheckIdPrefix|LabelPrefix|Label)\s*=\s*"(.+?)"', ps):
|
|
print(f'{m.group(1)} = "{m.group(2)}"')
|
|
|
|
# Find Write-CheckResult calls with variable CheckIds
|
|
print("\nWrite-CheckResult with variables:")
|
|
for m in re.finditer(r'Write-CheckResult\s+"(\$.+?)"\s+"(.+?)"', ps):
|
|
print(f' CheckId="{m.group(1)}" Desc="{m.group(2)[:80]}"')
|
|
|
|
# Also find the loop context around these calls
|
|
print("\nContext for variable-based checks:")
|
|
for m in re.finditer(r'(\$CheckIdPrefix\s*=\s*.+?)\n', ps):
|
|
start = max(0, m.start() - 50)
|
|
end = min(len(ps), m.end() + 300)
|
|
context = ps[start:end]
|
|
print(f' ---')
|
|
for line in context.split('\n')[:10]:
|
|
print(f' {line[:120]}')
|