本文整理汇总了Python中Scanner.load_rules方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.load_rules方法的具体用法?Python Scanner.load_rules怎么用?Python Scanner.load_rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.load_rules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload_rules
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import load_rules [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')
示例2:
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import load_rules [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)