Ejemplo n.º 1
0
def show_diff(cfg, left_name, right_name):
    prefixes = {
        '+': '{t.green}+{t.normal}'.format(t=terminal),
        '-': '{t.red}-{t.normal}'.format(t=terminal),
    }
    for symbol, app, src, dst in make_diff(
        sources.load_source(cfg, left_name),
        sources.load_source(cfg, right_name)):
        print "{pfx} {t.bold_cyan}{app}{t.normal} {t.yellow}{src}{t.normal} " \
              "-> {t.magenta}{dst}{t.normal}".format(
                t=terminal, pfx=prefixes[symbol], app=app, src=src, dst=dst)
 def __init__(self, source):
     if not os.path.exists('fwunit.yaml'):
         raise RuntimeError(
             'Tests must be run from the directory containing `fwunit.yaml`'
         )
     cfg = config.load_config('fwunit.yaml')
     self.source = sources.load_source(cfg, source)
 def run(self, args, cfg):
     terminal = Terminal()
     src = sources.load_source(cfg, args.source)
     if src.rulesPermit(args.src_ip, args.dst_ip, args.app):
         if not args.quiet:
             print terminal.black_on_green("Flow permitted")
     else:
         if not args.quiet:
             print terminal.black_on_red("Flow not permitted")
         sys.exit(1)
Ejemplo n.º 4
0
 def run(self, args, cfg):
     terminal = Terminal()
     src = sources.load_source(cfg, args.source)
     if src.rulesDeny(args.src_ip, args.dst_ip, args.app):
         if not args.quiet:
             print terminal.black_on_green("Flow denied")
     else:
         if not args.quiet:
             print terminal.black_on_red("Flow not denied")
         sys.exit(1)
 def run(self, args, cfg):
     src = sources.load_source(cfg, args.source)
     for app in sorted(src.allApps(args.src_ip, args.dst_ip)):
         print app
Ejemplo n.º 6
0
 def __init__(self, source):
     if not os.path.exists('fwunit.yaml'):
         raise RuntimeError('Tests must be run from the directory containing `fwunit.yaml`')
     cfg = config.load_config('fwunit.yaml')
     self.source = sources.load_source(cfg, source)
Ejemplo n.º 7
0
 def run(self, args, cfg):
     src = sources.load_source(cfg, args.source)
     for app in sorted(src.allApps(args.src_ip, args.dst_ip)):
         print app