def _check(version_compare_lst): compare_lst = ['>'] # avoid [>= 1.1, <= 1.0] for compare, _ in version_compare_lst: compare = compare.strip('=') if compare != compare_lst[-1]: compare_lst.append(compare) length = len(compare_lst) if version_compare_lst and 0 < length < 3: return True logger.warning('maybe framework or cms had be change by developer') if len(version_compare_lst) < 1: logger.warning( 'Reducing depth(--depth), set smaller number maybe useful') logger.error('unable to judge version') sys.exit() elif length > 2: logger.warning( 'Enlarge depth(--depth), set larger number or max(0) maybe useful' ) lst = [('version cond', )] for comb, ver in version_compare_lst: lst.append(('{} {}'.format(comb, ver), )) show_output(AsciiTable(lst).table) sys.exit()
def run(): """main function.""" args = call_parser() check_run_options(args) depend = args.depend logger.info('searching %s fingerprint infomation.....', depend) plugin_info = search(depend) if not plugin_info: logger.error('%s can not find a fingerprint of %s', APPNAME, depend) logger.info('your can use --all to print all fingerprint supported.') # TODO: show the request fingerprint url in github sys.exit() logger.info('already found %s fingerprint.', depend) distri = file_distribute(plugin_info) logger.info('start to request hash map on %s in depth %d.', args.url, args.depth) hash_map = static_hash_map(args.url, distri, args.depth) logger.verbose('show the hash map: %s', json.dumps(hash_map, indent=4, sort_keys=True)) logger.info('let\'s observer which version of %s.', depend) version_set = make_all(hash_map, plugin_info) cond_lst = [ VersionCond.from_str(''.join(comp)) for comp in calc(version_set) ] logger.info('show the possible versions of %s on %s', depend, args.url) result_lst = [('possible version', )] for version_str in plugin_info.get('versions'): if all((cond.match(version_str) for cond in cond_lst)): info = '{} v{}'.format(depend, version_str) logger.verbose(info) result_lst.append((info, )) show_output(AsciiTable(result_lst).table) sys.exit(0)
def check_run_options(args): """url(-u/--url) and frameworks name(-d/--depend) is required.""" if not args.url or not args.depend: logger.error( "url(-u/--url) and frameworks name(-d/--depend) is required") sys.exit()