本文整理汇总了Python中Scanner.scan_archive方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.scan_archive方法的具体用法?Python Scanner.scan_archive怎么用?Python Scanner.scan_archive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.scan_archive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scan
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import scan_archive [as 别名]
def scan():
file = request.files['file']
if file == False or allowed_file(file.filename) == False:
return Response(status=500, mimetype='application/json')
try:
if not os.path.exists(app.config['UPLOAD_FOLDER']):
os.makedirs(app.config['UPLOAD_FOLDER'])
if (len(Scanner.rulebase) == 0):
Scanner.load_yaml_rules(os.path.join(app.static_folder, 'default-rulebase.yml'))
file.save(os.path.join(app.config['UPLOAD_FOLDER'], file.filename))
results = Scanner.scan_archive(os.path.join(app.config['UPLOAD_FOLDER'], file.filename))
return Response(json.dumps(results, cls=JSONEncoderModels), mimetype='application/json')
except Exception as e:
logging.error(e)
return Response(status=500, mimetype='application/json')
示例2: upload_rules
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import scan_archive [as 别名]
def upload_rules():
file = request.files['file']
if file == False or allowed_file(file.filename) == False:
flash('Invalid File Upload Attempt')
return render_template('index.html')
try:
if request.form.get('submitbtn') == 'csv_load':
Scanner.load_rules(file)
flash('CSV Scan Rules Loaded')
return render_template('index.html')
except:
flash('CSV Rules Load Failed. Check Rules CSV file.')
return render_template('index.html')
try:
if request.form.get('submitbtn') == 'zip_scan':
results = Scanner.scan_archive(file)
return render_template('report.html', results=results, filename=file.filename)
except:
flash('ZIP File Scan Failed.')
return render_template('index.html')
示例3: scan_report
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import scan_archive [as 别名]
def scan_report():
file = request.files['file']
if file and allowed_file(file.filename):
results = Scanner.scan_archive(file)
return render_template('report.html', results=results, filename=file.filename)
return Response(status=500, mimetype='text/plain')
示例4:
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import scan_archive [as 别名]
#
# 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.
import argparse
import Scanner
from Models import JSONEncoderModels
import json
if __name__ == '__main__':
parser = argparse.ArgumentParser(prog='python -m ephemerol',
description='Scan a source archive for cloud readiness')
parser.add_argument('-c', help="Flags the rule file as a CSV based rule file. "
" Rules files are considered YAML by default.",
action='store_true')
parser.add_argument('rulefile', help='The file describing the rules the scanner should use')
parser.add_argument('archive', help='The source archive to scan')
args = parser.parse_args()
if args.c:
Scanner.load_rules(args.rulefile)
else:
Scanner.load_yaml_rules(args.rulefile)
results = Scanner.scan_archive(args.archive)
print json.dumps(results, cls=JSONEncoderModels, indent=1, sort_keys=True)