def parsing_commands(): """ Creation of an ArgumentParser object, holding all the information necessary to parse the command line into Python data types. """ parser = argparse.ArgumentParser(description='Given a list of directory or file paths,\ detects the malicious JS inputs.') parser.add_argument('--d', metavar='DIR', type=str, nargs='+', help='directories containing the JS files to be analyzed') parser.add_argument('--l', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious', '?'], help='labels of the JS directories to evaluate the model from') parser.add_argument('--f', metavar='FILE', type=str, nargs='+', help='files to be analyzed') parser.add_argument('--lf', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious', '?'], help='labels of the JS files to evaluate the model from') parser.add_argument('--m', metavar='MODEL', type=str, nargs=1, help='path of the model used to classify the new JS inputs ' '(see >$ python3 <path-of-clustering/learner.py> -help) ' 'to build a model)') parser.add_argument('--th', metavar='THRESHOLD', type=float, nargs=1, default=[0.50], help='threshold over which all samples are considered malicious') utility.parsing_commands(parser) return vars(parser.parse_args())
def parsing_commands(): """ Creation of an ArgumentParser object, holding all the information necessary to parse the command line into Python data types. """ parser = argparse.ArgumentParser( description='Given a list of directory or file paths,\ detects the malicious JS inputs.') parser.add_argument( '--d', metavar='DIR', type=str, nargs='+', help='directories containing the JS files to be analyzed') parser.add_argument( '--l', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious', '?'], help='labels of the JS directories to evaluate the model from') parser.add_argument('--f', metavar='FILE', type=str, nargs='+', help='files to be analyzed') parser.add_argument( '--lf', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious', '?'], help='labels of the JS files to evaluate the model from') parser.add_argument( '--m', metavar='MODEL', type=str, nargs=1, help='path of the model used to classify the new JS inputs') utility.parsing_commands(parser) return vars(parser.parse_args())
def parsing_commands_clustering(): """ Creation of an ArgumentParser object, holding all the information necessary to parse the command line into Python data types. ------- Returns: - ArgumentParser such as: * js_dirs=args['d'], * js_files=args['f'], * tolerance=args['t'][0], * n=args['n'][0], * nb_cluster=args['c'][0], * display_fig=args['g'][0], * labels_d=arg_obj['l'], * labels_f=arg_obj['lf']. A more thorough description can be obtained: >$ python3 <path-of-clustering/cluster.py> -help """ parser = argparse.ArgumentParser(description='Given a list of repository or file paths,\ clusters the JS inputs into several families.') parser.add_argument('--d', metavar='DIR', type=str, nargs='+', help='directories containing the JS files to be clustered') parser.add_argument('--f', metavar='FILE', type=str, nargs='+', help='files to be analyzed') parser.add_argument('--c', metavar='INTEGER', type=int, nargs=1, help='number of clusters') parser.add_argument('--g', metavar='BOOL', type=bool, nargs=1, default=[False], help='produces a 2D representation of the files from the JS corpus') parser.add_argument('--l', metavar='LABEL', type=str, nargs='+', default=None, help='true labels of the JS directories (used only for display)') parser.add_argument('--lf', metavar='LABEL', type=str, nargs='+', default=None, help='true labels of the JS files (used only for display)') utility.parsing_commands(parser) return vars(parser.parse_args())
def parsing_commands(): """ Creation of an ArgumentParser object, holding all the information necessary to parse the command line into Python data types. ------- Returns: - ArgumentParser such as: * js_dirs=arg_obj['d'], * labels_d=arg_obj['l'], * js_files=arg_obj['f'], * labels_f=arg_obj['lf'], * old_model=arg_obj['m'][0], * model_dir=arg_obj['md'][0], * model_name=arg_obj['mn'][0], * add_trees=arg_obj['at'][0], * tolerance=arg_obj['t'][0], * n=arg_obj['n'][0]. A more thorough description can be obtained: >$ python3 <path-of-clustering/learner.py> -help """ parser = argparse.ArgumentParser( description='Given a list of directory or file paths, ' + 'updates a model to classify future ' + 'JS inputs.') parser.add_argument('--d', metavar='DIR', type=str, nargs='+', help='directories to be used to update a model with') parser.add_argument( '--l', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious'], help='labels of the JS directories used to update a model with') parser.add_argument('--f', metavar='FILE', type=str, nargs='+', help='files to be used to update a model with') parser.add_argument( '--lf', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious'], help='labels of the JS files used to update a model with') parser.add_argument( '--m', metavar='OLD-MODEL', type=str, nargs=1, help='path of the old model you wish to update with new JS inputs') parser.add_argument('--md', metavar='MODEL-DIR', type=str, nargs=1, default=[os.path.join(src_path, 'Classification')], help='path to store the model that will be produced') parser.add_argument('--mn', metavar='MODEL-NAME', type=str, nargs=1, default=['model'], help='name of the model that will be produced') parser.add_argument('--at', metavar='NB_TREES', type=int, nargs=1, default=[100], help='number of trees to be added into the forest') utility.parsing_commands(parser) return vars(parser.parse_args())
def parsing_commands(): """ Creation of an ArgumentParser object, holding all the information necessary to parse the command line into Python data types. ------- Returns: - ArgumentParser such as: * js_dirs=arg_obj['d'], * labels_d=arg_obj['l'], * js_files=arg_obj['f'], * labels_f=arg_obj['lf'], * model_dir=arg_obj['md'][0], * model_name=arg_obj['mn'][0], * print_score=arg_obj['ps'][0], * print_res=arg_obj['pr'][0], * estimators=arg_obj['nt'][0], * tolerance=arg_obj['t'][0], * n=arg_obj['n'][0]. A more thorough description can be obtained: >$ python3 <path-of-clustering/learner.py> -help """ parser = argparse.ArgumentParser( description='Given a list of directory or file paths, ' + 'builds a model to classify future ' + 'JS inputs.') parser.add_argument('--d', metavar='DIR', type=str, nargs='+', help='directories to be used to build a model from') parser.add_argument( '--l', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious'], help='labels of the JS directories used to build a model from') parser.add_argument('--f', metavar='FILE', type=str, nargs='+', help='files to be used to build a model from') parser.add_argument( '--lf', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious'], help='labels of the JS files used to build a model from') parser.add_argument('--md', metavar='MODEL-DIR', type=str, nargs=1, default=[os.path.join(src_path, 'Classification')], help='path to store the model that will be produced') parser.add_argument('--mn', metavar='MODEL-NAME', type=str, nargs=1, default=['model'], help='name of the model that will be produced') parser.add_argument( '--ps', metavar='BOOL', type=bool, nargs=1, default=[False], help= 'indicates whether to print or not the classifier\'s detection rate') parser.add_argument( '--pr', metavar='BOOL', type=bool, nargs=1, default=[False], help='indicates whether to print or not the classifier\'s predictions') parser.add_argument('--nt', metavar='NB_TREES', type=int, nargs=1, default=[500], help='number of trees in the forest') utility.parsing_commands(parser) return vars(parser.parse_args())
def parsing_commands(): """ Creation of an ArgumentParser object, holding all the information necessary to parse the command line into Python data types. """ parser = argparse.ArgumentParser( description='Given a list of directory or file paths, ' 'builds a model to classify future ' 'JS inputs.') parser.add_argument('--d', metavar='DIR', type=str, nargs='+', help='directories to be used to build a model from') parser.add_argument( '--l', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious'], help='labels of the JS directories used to build a model from') parser.add_argument( '--vd', metavar='DIR-VALIDATE', type=str, nargs='+', help='2 JS dir (1 benign, 1 malicious) to select the features with chi2' ) parser.add_argument( '--vl', metavar='LABEL', type=str, nargs='+', choices=['benign', 'malicious'], help='labels of the 2 JS dir for the features selection process') parser.add_argument('--md', metavar='MODEL-DIR', type=str, nargs=1, default=[os.path.join(SRC_PATH, 'Analysis')], help='path to store the model that will be produced') parser.add_argument('--mn', metavar='MODEL-NAME', type=str, nargs=1, default=['model'], help='name of the model that will be produced') parser.add_argument( '--ps', metavar='BOOL', type=bool, nargs=1, default=[False], help= 'indicates whether to print or not the classifier\'s detection rate') parser.add_argument( '--pr', metavar='BOOL', type=bool, nargs=1, default=[False], help='indicates whether to print or not the classifier\'s predictions') parser.add_argument('--nt', metavar='NB_TREES', type=int, nargs=1, default=[500], help='number of trees in the forest') utility.parsing_commands(parser) return vars(parser.parse_args())