Merge pull request #1 from JPSxzy8/patch-1

initCommonOutputs: Allow prediction of outputs containing `#`
This commit is contained in:
JPSxzy8 2024-01-12 16:36:49 +01:00 committed by GitHub
commit 3ee80bd411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,7 @@ import time
import types
import unicodedata
from collections import defaultdict
from difflib import SequenceMatcher
from math import sqrt
from optparse import OptionValueError
@ -2517,11 +2518,15 @@ def initCommonOutputs():
True
"""
kb.commonOutputs = {}
kb.commonOutputs = defaultdict(set)
key = None
for line in openFile(paths.COMMON_OUTPUTS, 'r'):
if line.find('#') != -1:
# "Escaped" lines are read in raw mode, this allows predicting
# outputs that contains "#", e.g: `\##MS_PolicyEventProcessingLogin##`
if line.startswith("\\"):
line = line[1:]
elif line.find('#') != -1:
line = line[:line.find('#')]
line = line.strip()
@ -2530,11 +2535,7 @@ def initCommonOutputs():
if line.startswith('[') and line.endswith(']'):
key = line[1:-1]
elif key:
if key not in kb.commonOutputs:
kb.commonOutputs[key] = set()
if line not in kb.commonOutputs[key]:
kb.commonOutputs[key].add(line)
kb.commonOutputs[key].add(line)
def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, unique=False):
"""