本文整理汇总了Python中Scanner.load_yaml_rules方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.load_yaml_rules方法的具体用法?Python Scanner.load_yaml_rules怎么用?Python Scanner.load_yaml_rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.load_yaml_rules方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_rules
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import load_yaml_rules [as 别名]
def load_rules():
file = request.files['file']
if file == False or allowed_file(file.filename) == False:
return Response(status=500, mimetype='application/json')
try:
file_path = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
file.save(file_path)
Scanner.load_yaml_rules(file_path)
return Response(status=200, mimetype='application/json')
except Exception as e:
logging.error(e)
return Response(status=500, mimetype='application/json')
示例2: scan
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import load_yaml_rules [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')
示例3:
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import load_yaml_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)