Example #1
0
def xml_file_scan(file_lines, filename):
    xmlrules = []
    global scan_results
    for rule in rulebase:
        if (rule.file_type == "config") and (rule.file_name == "*.xml") and (rule.text_pattern != "NONE"):
            xmlrules.append(rule)

    for line in file_lines:
        for rule in xmlrules:
            if rule.text_pattern in line:
                scan_results.append(ScanResult(scan_item=rule, flagged_file_id=filename))
Example #2
0
def cs_file_scan(file_lines, filename):
    cs_file_rules = []
    global scan_results
    for rule in rulebase:
        if (rule.file_type == "csharp") \
                and (rule.app_type == "dotnet") \
                and (rule.file_name == "*.cs") \
                and (rule.text_pattern != "NONE"):
            cs_file_rules.append(rule)
    for line in file_lines:
        for rule in cs_file_rules:
            if rule.text_pattern in line:
                scan_results.append(ScanResult(scan_item=rule, flagged_file_id=filename))
Example #3
0
def java_file_scan(file_lines, filename):
    javarules = []
    global scan_results
    for rule in rulebase:
        if (rule.file_type == "java") \
                and (rule.app_type == "java") \
                and (rule.file_name == "*.java") \
                and (rule.text_pattern != "NONE"):
            javarules.append(rule)
    for line in file_lines:
        for rule in javarules:
            if rule.text_pattern in line:
                scan_results.append(ScanResult(scan_item=rule, flagged_file_id=filename))
Example #4
0
def config_scan(file_path_list):
    configrules = []
    global scan_results

    for rule in rulebase:
        if (rule.file_type == "config") and (rule.app_type == "java"):
            configrules.append(rule)

    for path in file_path_list:
        if path.endswith('/'):
            path = path[:-1]
        file_name = path.split('/')[-1]
        for configrule in configrules:
            if file_name == configrule.file_name:
                scan_results.append(ScanResult(scan_item=configrule, flagged_file_id=file_name))