Exemplo n.º 1
0
def main():
    args = parse_args()

    linux_products, other_products = ssg.products.get_all(SSG_ROOT)
    all_products = linux_products.union(other_products)

    left_file = open(args.left, 'r')
    left_rules = json.load(left_file)

    right_file = open(args.right, 'r')
    right_rules = json.load(right_file)

    if left_rules == right_rules:
        print(
            "No difference. Please use rule_dir_stats to inspect one of these files."
        )
        sys.exit(0)

    if args.products.lower() == 'all':
        args.products = all_products
    elif args.products.lower() == 'linux':
        args.products = linux_products
    elif args.products.lower() == 'other':
        args.products = other_products
    else:
        args.products = args.products.split(',')
    args.products = set(args.products)

    left_query_keys = rds.filter_rule_ids(set(left_rules), args.query)
    right_query_keys = rds.filter_rule_ids(set(right_rules), args.query)
    args.query = left_query_keys.union(right_query_keys)
    print("Total number of queried rules: %d\n" % len(args.query))

    if not args.missing and not args.two_plus and not args.prodtypes and not args.product_names:
        args.missing = True
        args.two_plus = True
        args.prodtypes = True

    print("< Total number of known rule directories: %d" % len(left_rules))
    print("> Total number of known rule directories: %d\n" % len(right_rules))
    print("= Total number of queried rules: %d\n" % len(args.query))

    if args.missing:
        process_diff_missing(args, left_rules, right_rules)
    if args.two_plus:
        process_diff_two_plus(args, left_rules, right_rules)
    if args.prodtypes:
        process_diff_prodtypes(args, left_rules, right_rules)
    if args.product_names:
        process_diff_product_names(args, left_rules, right_rules)
def main():
    args = parse_args()

    linux_products, other_products = ssg.products.get_all(SSG_ROOT)
    all_products = linux_products.union(other_products)

    left_file = open(args.left, 'r')
    left_rules = json.load(left_file)

    right_file = open(args.right, 'r')
    right_rules = json.load(right_file)

    if left_rules == right_rules:
        print("No difference. Please use rule_dir_stats to inspect one of these files.")
        sys.exit(0)

    if args.products.lower() == 'all':
        args.products = all_products
    elif args.products.lower() == 'linux':
        args.products = linux_products
    elif args.products.lower() == 'other':
        args.products = other_products
    else:
        args.products = args.products.split(',')
    args.products = set(args.products)

    left_query_keys = rds.filter_rule_ids(set(left_rules), args.query)
    right_query_keys = rds.filter_rule_ids(set(right_rules), args.query)
    args.query = left_query_keys.union(right_query_keys)
    print("Total number of queried rules: %d\n" % len(args.query))

    if not args.missing and not args.two_plus and not args.prodtypes and not args.product_names:
        args.missing = True
        args.two_plus = True
        args.prodtypes = True

    print("< Total number of known rule directories: %d" % len(left_rules))
    print("> Total number of known rule directories: %d\n" % len(right_rules))
    print("= Total number of queried rules: %d\n" % len(args.query))

    if args.missing:
        process_diff_missing(args, left_rules, right_rules)
    if args.two_plus:
        process_diff_two_plus(args, left_rules, right_rules)
    if args.prodtypes:
        process_diff_prodtypes(args, left_rules, right_rules)
    if args.product_names:
        process_diff_product_names(args, left_rules, right_rules)
def main():
    args = parse_args()

    linux_products, other_products = ssg.products.get_all(SSG_ROOT)
    all_products = linux_products.union(other_products)

    json_file = open(args.input, 'r')
    known_rules = json.load(json_file)

    if args.products.lower() == 'all':
        args.products = all_products
    elif args.products.lower() == 'linux':
        args.products = linux_products
    elif args.products.lower() == 'other':
        args.products = other_products
    else:
        args.products = args.products.split(',')
    args.products = set(args.products)

    args.query = rds.filter_rule_ids(set(known_rules), args.query)

    if not args.missing and not args.two_plus and not args.prodtypes and not args.introspect and not args.unassociated and not args.product_names:
        args.missing = True
        args.two_plus = True
        args.prodtypes = True

    print("Total number of known rule directories: %d" % len(known_rules))
    print("Total number of queried rules: %d\n" % len(args.query))

    if args.missing:
        process_missing(args, known_rules)
    if args.two_plus:
        process_two_plus(args, known_rules)
    if args.prodtypes:
        process_prodtypes(args, known_rules)
    if args.product_names:
        process_product_names(args, known_rules)
    if args.introspect and args.query:
        process_introspection(args, known_rules)
    if args.unassociated:
        process_unassociated(args, known_rules, all_products)
def main():
    args = parse_args()

    linux_products, other_products = ssg.products.get_all(SSG_ROOT)
    all_products = linux_products.union(other_products)

    json_file = open(args.input, 'r')
    known_rules = json.load(json_file)

    if args.products.lower() == 'all':
        args.products = all_products
    elif args.products.lower() == 'linux':
        args.products = linux_products
    elif args.products.lower() == 'other':
        args.products = other_products
    else:
        args.products = args.products.split(',')
    args.products = set(args.products)

    args.query = rds.filter_rule_ids(set(known_rules), args.query)

    if not args.missing and not args.two_plus and not args.prodtypes and not args.introspect and not args.unassociated and not args.product_names:
        args.missing = True
        args.two_plus = True
        args.prodtypes = True

    print("Total number of known rule directories: %d" % len(known_rules))
    print("Total number of queried rules: %d\n" % len(args.query))

    if args.missing:
        process_missing(args, known_rules)
    if args.two_plus:
        process_two_plus(args, known_rules)
    if args.prodtypes:
        process_prodtypes(args, known_rules)
    if args.product_names:
        process_product_names(args, known_rules)
    if args.introspect and args.query:
        process_introspection(args, known_rules)
    if args.unassociated:
        process_unassociated(args, known_rules, all_products)