用于分析或提高gcp云资源gcp安全性的小软件包

gcpsecurit的Python项目详细描述


这个包有助于提高GCP项目的安全性,并通过执行一些检查减少未使用资源的计费

此脚本适用于不在组织或文件夹级别的单个GCP项目


包装安装

pip3 install gcpsecurity

确保google云平台API为您想要执行检查的特定服务启用

^{pr2}$

如何使用??在

step 1: Import classes to perform checks

    from gcpsecurity.gcp_data_proc import ExecuteCheckDp
    from gcpsecurity.gcp_gke import ExecuteCheckGke

step 2: Create GCP service account with project viewer permission
step 3: Initlize ExecuteCheck class with service account file path and project id

    dp = ExecuteCheckDp(servive_account_file_path=SERVICE_ACCOUNT_FILE_PATH, project_id=PROJECT_ID)
    gke = ExecuteCheckGke(servive_account_file_path=SERVICE_ACCOUNT_FILE_PATH, project_id=PROJECT_ID)


step 4: Call perform_check() method of ExecuteCheck classes object

        dp_result = dp.perform_check()
        gke_result = gke.perform_check()

step 5: Print results

        print(dp_result)
        print(gke_result)

可用服务检查类:

    compute engine checks ==> from gcpsecurity.gcp_vm import ExecuteCheckVm
    IAM checks            ==> from gcpsecurity.gcp_iam import ExecuteCheckIam
    VPC checks            ==> from gcpsecurity.gcp_vpc import ExecuteCheckVpc
    cloud storage         ==> from gcpsecurity.gcp_gcs import ExecuteCheckGcs
    cloud sql             ==> from gcpsecurity.gcp_cloud_sql import ExecuteCheckSql
    app engine            ==> from gcpsecurity.gcp_app_engine import ExecuteCheckGae
    data proc             ==> from gcpsecurity.gcp_data_proc import ExecuteCheckDp
    kubernetes engine     ==> gcpsecurity.gcp_gke import ExecuteCheckGke

示例脚本

    https://github.com/Aadeshkale/gcp-security/blob/master/main.py 

**注:

  1. 脚本可能需要一些时间来执行,因为它正在进行googleapis调用。在

  2. 服务帐户文件应具有适当的权限来执行Project Viewer检查(您也可以根据服务设置权限)

  3. 要根据您的使用添加其他检查,请转到包gcpsecurity在现有服务脚本中添加检查或为新服务添加新脚本 参考号:-https://github.com/Aadeshkale/gcp-security/tree/master/gcpsecurity

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java@AfterEach注释在Spring测试中被忽略   散列如何使用bouncy castle在Java中创建SHA512摘要字符串?   java无法使用Okhttp获取响应cookie   100个数的java阶乘   多线程如何在Java中实现对象计数器   java我的精灵不显示背景   java如何在com上应用PanelSlideListener。索特里。滑动面板。SlidengUpPanelLayout SlideUp库   java如何在JDBC中使用WHERE EXISTS函数   java Swing:标签前景中的白色被绘制为黑色   获取java的时间戳。util。另一个java的日期对象为(10/7/14)。util。日期对象(2014年10月7日星期二11:21:00)   java如何在Spring/OpenJPA 1中重新创建用于更新行锁定的选择   java在保存另一个maven项目中的类时,有没有办法让eclipse识别对该类的更改?   java如何解决Spring中的Servlet上下文错误?   java在mongodb中删除记录   显示的java片段与当前片段重叠,而不是替换它