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


Python Scanner.load_rules方法代码示例

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

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


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