当前位置: 首页>>代码示例>>Python>>正文


Python Scanner.load_yaml_rules方法代码示例

本文整理汇总了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')
开发者ID:Pivotal-Field-Engineering,项目名称:ephemerol,代码行数:16,代码来源:ephemerol-web.py

示例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')
开发者ID:Pivotal-Field-Engineering,项目名称:ephemerol,代码行数:21,代码来源:ephemerol-web.py

示例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)
开发者ID:Pivotal-Field-Engineering,项目名称:ephemerol,代码行数:32,代码来源:__main__.py


注:本文中的Scanner.load_yaml_rules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。