当前位置: 首页>>代码示例>>Python>>正文


Python Scanner.output方法代码示例

本文整理汇总了Python中scanner.Scanner.output方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.output方法的具体用法?Python Scanner.output怎么用?Python Scanner.output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scanner.Scanner的用法示例。


在下文中一共展示了Scanner.output方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import output [as 别名]
def main():
    # Include current path in case we attempt to load modules.
    sys.path.append(os.getcwd())

    parser = argparse.ArgumentParser("Runs a set of tests against the set of provided URLs")
    parser.add_argument("-u", "--url", action="append", dest="targets", help="Add a target to test")
    parser.add_argument("-f", "--target-file", action="append", dest="target_files", help="File with URLs to test")

    parser.add_argument("-m", "--module", action="append", default = [], dest="modules", help="Load an extension module")
    parser.add_argument("-D", "--disable-core", action="store_true", default = False, dest="disable_core", help="Disable corechecks")
    parser.add_argument("-p", "--force-passive", action="store_true", default=False, dest="force_passives", help ="Force passives to be run for each active test")
    parser.add_argument("-d", "--dns", action="store_false", default=True, dest="resolve_target", help ="Skip DNS resolution when registering a target")
    parser.add_argument("-r", "--report", action="store", default="xml", dest="report",help="Load a reporter e.g. -r reporter.AntXmlReporter")
    parser.add_argument("-o", "--output", action="store", default="garmr-results.xml", dest="output", help="Default output is garmr-results.xml")
    parser.add_argument("-c", "--check", action="append", dest="opts", help="Set a parameter for a check (check:opt=value)" )
    parser.add_argument("-e", "--exclude", action="append", dest="exclusions", help="Prevent a check from being run/processed")
    parser.add_argument("--save", action="store", dest="dump_path", help="Write out a configuration file based on parameters (won't run scan)")
    
    args = parser.parse_args()
    scanner = Scanner()
    
    scanner.force_passives = args.force_passives
    scanner.resolve_target = args.resolve_target
    scanner.output = args.output
     
    # Start building target list.
    if args.targets != None:
        for target in args.targets:
            scanner.register_target(target)
        
    # Add targets from files to the list.
    if args.target_files != None:
        for targets in args.target_files:
            try:
                f = open(targets, "r")
                for target in f:
                    t = target.strip()
                    if len(t) > 0:
                        scanner.register_target(t)
            except:
                Scanner.logger.error("Unable to process the target list in: %s", targets)
    
    # Load built-in modules if required.
    if args.disable_core == False:
		corechecks.configure(scanner)
		
    # Configure modules.
    # TODO: change the module loading to scan the list of classes in a module and automagically 
    #       detect any tests defined.
    if args.modules != None:
        for module in args.modules:
            try:
                __import__(module)
                m = sys.modules[module]
                m.configure(scanner)
            except Exception, e:
                Scanner.logger.fatal("Unable to load the requested module [%s]: %s", module, e)
                quit()
开发者ID:stephendonner,项目名称:Garmr,代码行数:60,代码来源:garmr.py


注:本文中的scanner.Scanner.output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。