diff options
| author | Johan Lundberg <lundberg@nordu.net> | 2015-04-02 10:43:33 +0200 |
|---|---|---|
| committer | Johan Lundberg <lundberg@nordu.net> | 2015-04-02 10:43:33 +0200 |
| commit | bd611ac59f7c4db885a2f8631ef0bcdcd1901ca0 (patch) | |
| tree | e60f5333a7699cd021b33c7f5292af55b774001b /aclcheck_cmdline.py | |
Diffstat (limited to 'aclcheck_cmdline.py')
| -rwxr-xr-x | aclcheck_cmdline.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/aclcheck_cmdline.py b/aclcheck_cmdline.py new file mode 100755 index 0000000..fca8bbf --- /dev/null +++ b/aclcheck_cmdline.py @@ -0,0 +1,58 @@ +#!/usr/bin/python +# +# Copyright 2011 Google Inc. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Command line interface to aclcheck library.""" + +__author__ = 'watson@google.com (Tony Watson)' + +from optparse import OptionParser +import sys +from lib import aclcheck +from lib import policy +from lib import naming + + +def main(): + usage = "usage: %prog [options] arg" + _parser = OptionParser(usage) + _parser.add_option('--definitions-directory', dest='definitions', + help='definitions directory', default='./def') + _parser.add_option('-p', '--policy-file', dest='pol', + help='policy file', default='./policies/sample.pol') + _parser.add_option('-d', '--destination', dest='dst', + help='destination IP', default='200.1.1.1') + _parser.add_option('-s' ,'--source', dest='src', + help='source IP', default='any') + _parser.add_option('--proto', '--protocol', dest='proto', + help='Protocol (tcp, udp, icmp, etc.)', default='tcp') + _parser.add_option('--dport', '--destination-port', dest='dport', + help='destination port', default='80') + _parser.add_option('--sport', '--source-port', dest='sport', + help='source port', default='1025') + (FLAGS, args) = _parser.parse_args() + #if FLAGS.help: + # print _parser.format_help() + + defs = naming.Naming(FLAGS.definitions) + policy_obj = policy.ParsePolicy(open(FLAGS.pol).read(), defs) + check = aclcheck.AclCheck(policy_obj, src=FLAGS.src, dst=FLAGS.dst, + sport=FLAGS.sport, dport=FLAGS.dport, + proto=FLAGS.proto) + print str(check) + +if __name__ == '__main__': + main() |
