Пример #1
0
def list_transforms(args):

    # TODO: project_tree may raise an exception if either project_root can't be
    # determined or if we can't find the package as an installed package.
    # Atleast the create-transform command calls this function without handling
    # the possible exception.  What is the best sollution?

    # TODO: create-transform takes an argument --transform-dir which can be used
    # to control where to place the transform template. This breaks the new
    # assumption of the 'transforms' folder always being inside the 'pkg'
    # folder.  However this is an assumption all over the place, so this
    # parameter doesn't really make much sense?

    # TODO: There are most likely many commands with similar problems
    # (above). and perhaps they should be updated to use the below template and
    # have their argument updated to -d/--dir instead with CWD as the default
    # value.

    # TODO: Perhaps we should introduce a 'create' command that will just make
    # an empty canari root dir (project). Inside this we can then call
    # create-package a number of times to generate all the desired
    # packages. This could even be automated for N-times during the call to
    # 'create'. 'create-package' can even still default to call 'create' if not
    # inside a canari root directory, to preserve backwards compatability.

    # TODO: Handle hyphening of package names. When creating them and when
    # trying to access them.  This goes for project_tree, it should change '-'
    # with '_' in the package name.

    try:
        with pushd(args.dir):
            opts = parse_args(args)

        with pushd(args.ptree['src']):

            transform_package = TransformDistribution(opts.package)
            for t in transform_package.transforms:
                print('`- %s: %s' % (highlight(
                    t.__name__, 'green', True), t.dotransform.description))
                print(highlight('  `- Maltego identifiers:', 'black', True))
                for uuid, (input_set,
                           input_type) in zip(t.dotransform.uuids,
                                              t.dotransform.inputs):
                    print '    `- %s applies to %s in set %s' % (
                        highlight(uuid, 'red', False),
                        highlight(input_type._type_, 'red',
                                  False), highlight(input_set, 'red', False))
                print ''
    except ValueError, e:
        print str(e)
        exit(-1)
Пример #2
0
def list_transforms(args):

    # TODO: project_tree may raise an exception if either project_root can't be
    # determined or if we can't find the package as an installed package.
    # Atleast the create-transform command calls this function without handling
    # the possible exception.  What is the best sollution?

    # TODO: create-transform takes an argument --transform-dir which can be used
    # to control where to place the transform template. This breaks the new
    # assumption of the 'transforms' folder always being inside the 'pkg'
    # folder.  However this is an assumption all over the place, so this
    # parameter doesn't really make much sense?

    # TODO: There are most likely many commands with similar problems
    # (above). and perhaps they should be updated to use the below template and
    # have their argument updated to -d/--dir instead with CWD as the default
    # value.

    # TODO: Perhaps we should introduce a 'create' command that will just make
    # an empty canari root dir (project). Inside this we can then call
    # create-package a number of times to generate all the desired
    # packages. This could even be automated for N-times during the call to
    # 'create'. 'create-package' can even still default to call 'create' if not
    # inside a canari root directory, to preserve backwards compatability.

    # TODO: Handle hyphening of package names. When creating them and when
    # trying to access them.  This goes for project_tree, it should change '-'
    # with '_' in the package name.

    try:
        with pushd(args.dir):
            opts = parse_args(args)

        with pushd(args.ptree['src']):

            transform_package = TransformDistribution(opts.package)
            for t in transform_package.transforms:
                print ('`- %s: %s' % (highlight(t.__name__, 'green', True), t.dotransform.description))
                print (highlight('  `- Maltego identifiers:', 'black', True))
                for uuid, (input_set, input_type) in zip(t.dotransform.uuids, t.dotransform.inputs):
                    print '    `- %s applies to %s in set %s' % (
                        highlight(uuid, 'red', False),
                        highlight(input_type._type_, 'red', False),
                        highlight(input_set, 'red', False)
                    )
                print ''
    except ValueError, e:
        print str(e)
        exit(-1)
Пример #3
0
def create_profile(args):

    opts = parse_args(args)
    current_dir = os.getcwd()
    try:
        with pushd(opts.working_dir or current_dir):
            transform_package = TransformDistribution(opts.package)
            transform_package.create_profile(opts.working_dir, current_dir)
    except ValueError, e:
        print(str(e))
        exit(-1)
Пример #4
0
def create_profile(args):

    opts = parse_args(args)
    current_dir = os.getcwd()
    try:
        with pushd(opts.working_dir or current_dir):
            transform_package = TransformDistribution(opts.package)
            transform_package.create_profile(opts.working_dir, current_dir)
    except ValueError, e:
        print(str(e))
        exit(-1)
Пример #5
0
def install_package(args):

    opts = parse_args(args)

    try:
        with pushd(opts.working_dir or os.getcwd()):
            transform_package = TransformDistribution(opts.package)
            transform_package.install(opts.working_dir, opts.settings_dir)
    except ValueError, e:
        print str(e)
        exit(-1)
Пример #6
0
def shell(opts):

    fix_binpath(config['default/path'])
    fix_pypath()

    if not opts.package.endswith('transforms'):
        opts.package = '%s.transforms' % opts.package

    try:
        t = TransformDistribution(opts.package)
        with pushd(opts.working_dir or t.default_prefix):
            mtg_console = MtgConsole(opts.package)
            mtg_console.interact(highlight('Welcome to Canari %s.' % canari.__version__, 'green', True))
    except ValueError, e:
        print str(e)
        exit(-1)
Пример #7
0
def shell(opts):

    fix_binpath(config['default/path'])
    fix_pypath()

    if not opts.package.endswith('transforms'):
        opts.package = '%s.transforms' % opts.package

    try:
        t = TransformDistribution(opts.package)
        with pushd(opts.working_dir or t.default_prefix):
            mtg_console = MtgConsole(opts.package)
            mtg_console.interact(
                highlight('Welcome to Canari %s.' % canari.__version__,
                          'green', True))
    except ValueError, e:
        print str(e)
        exit(-1)
Пример #8
0
def list_transforms(args):

    opts = parse_args(args)

    try:
        with pushd(opts.working_dir or os.getcwd()):
            transform_package = TransformDistribution(opts.package)
            for t in transform_package.transforms:
                print('`- %s: %s' % (highlight(
                    t.__name__, 'green', True), t.dotransform.description))
                print(highlight('  `- Maltego identifiers:', 'black', True))
                for uuid, (input_set,
                           input_type) in zip(t.dotransform.uuids,
                                              t.dotransform.inputs):
                    print '    `- %s applies to %s in set %s' % (
                        highlight(uuid, 'red', False),
                        highlight(input_type._type_, 'red',
                                  False), highlight(input_set, 'red', False))
                print ''
    except ValueError, e:
        print str(e)
        exit(-1)
Пример #9
0
#!/bin/env python3

from common import pushd, popd, Package, argv_parse, setup_enviroment
from subprocess import check_call as run, check_output
from os.path import join, getmtime, exists, basename, dirname

config, pkgs = argv_parse()
while len(pkgs):
    pkg = pkgs.pop()
    pushd(pkg.directory)
    fname = pkg.filename()
    if not exists(fname) or getmtime(pkg.pkgbuild) > getmtime(fname):
        run(["makepkg", "-Cfp", pkg.pkgbuild])
        run(["yaourt", "-U", fname])
    popd()
    for p in pkgs:
        if pkg.name in p.dependencies:
            p.dependencies.remove(pkg.name)
    pkgs.sort(key=Package.sortkey, reverse=True)