🧑‍🏫
liualexiang
  • Introduction
  • Azure
    • AKS Basic
    • AKS Spark
    • AZ ACR SYNC
    • Azure CMI SDWAN
    • Azure LB DeepDive
      • Azure LB DeepDive
    • Azure Service Principal Basic
    • Azure Internal VM Network Connectivity
      • Azure Internal VM Network Connectivity
    • Azure Cli Build
    • Azure Vm Memory Monitor
  • Blockchain
    • BTC
  • CRISPR
    • 使用Parallel_Cluster提升CRISPA效率
  • OpenSource
    • ElasticSearch
      • ES Get Started
      • ES Search Query
      • Kibana 可视化
      • Logstash配置
    • Ansible 基础
    • Infra As Code
      • Pulumi Get Started
      • Terraform Basic
    • ZooKeeper 基础
    • RPC与REST
    • 使用Python申请大量内存测试
    • 使用TPC_DS产生压测数据
    • Superset
      • Superset部署手册
    • 代码扫描
    • Git
      • Git Basic
      • Github Action Basic
      • Gitlab与AzureAD集成
      • Gitbook 基础教程
    • K8S
      • enter_node
      • K8s X509 Client Cert
      • K8s Basic
      • K8s Oidc
      • Docker 基础
      • helm基础
      • K8S_Secrets管理
      • 深入了解K8S
      • 混沌工程
      • Istio
      • 生态
      • CRD开发
      • k8s网络
    • Cloud_Custodian
    • Jenkins Basic
    • Nginx
    • ETCD
    • 正则
    • VictoriaMetrics
    • Kafka
  • MySQL
    • MySQL 调优
  • Linux
    • SSH Tunnel 上网
    • 内存管理
    • 在Linux系统中通过LUKS加密磁盘
    • 量子计算 Basic
    • IO多路复用
    • Iptables
    • tmux和screen
    • Systemd
    • OS 基础
    • jq基础
    • yum
    • neovim
  • Web
    • Html Css
    • Web部署
    • 缓存
  • Programming
    • 算法
      • 返回list中最大生序子序列长度
    • Python技巧
      • Python的语法糖
      • Python常用装饰器
      • AsyncIO基础
      • 自动化测试pytest
      • python中的下划线
      • 面向对象
      • Python的坑
      • Python配置文件管理
      • HTTP Stream Response
      • Python项目管理
    • 设计模式
      • 设计模式
      • 面向对象的思想
      • 编程概念
    • Go
      • Go 基础
      • Go常用功能
      • 结构体入门
    • 前端
    • Vue
    • NodeJS
  • Math
    • 多项式插值法
  • Security
    • HTTP常见攻击
    • 加密与签名
    • RSA
    • ECDSA
  • Solidity
    • Solidity基础
    • Blockchain Testnet Faucet
  • Tools
    • 视频处理ffmpeg
    • IDE配置
    • iTerm2美化
    • 密码管理
    • FRP配置
    • 工具集
由 GitBook 提供支持
在本页
  • schema 检查
  • 检查安全组的示例
  1. OpenSource

Cloud_Custodian

c7n 支持几种模式,比如直接在本机执行,基于资源进行扫描,基于cloudtrail进行扫描,或者跟 aws 的config集成。在执行的时候,也能通过 action 直接对资源进行修复操作,如删除,或者发通知到slack等

schema 检查

custodian schema aws.security-group.filters.ingress

检查安全组的示例

policies:
  - name: security-groups-with-test-description
    resource: security-group
    filters:
      - or:
        - type: ingress
          Description:
            value: "test"
            op: contains
        - type: ingress
          Description:
            value: "manual"
            op: contains
        - type: ingress
          Description:
            value: "manually"
            op: contains
            

执行

custodian run -s output sg-with-test.yaml --cache-period 0
custodian report -s output sg-with-test.yaml --format grid

注意上面的type是 ingress,如果 c7n 没有针对这个类型做处理的话,也可以通过对 type: value 对value进行过滤处理,value里的内容格式可以在 output/resources.json 里查看

上面的检查安全组的示例,也可以用这种方法

policies:
  - name: security-groups-with-test-description
    resource: aws.security-group
    filters:
      - type: list-item
        key: IpPermissions[].UserIdGroupPairs[]
        attrs:
          - type: value
            key: Description
            op: contains
            value: "test"

之所以不直接使用 type: value的过滤器,而使用 ingress 或 list-item 过滤器,是因为type:value 对安全组的 IpPermissions[].UserIdGroupPairs[] 过滤之后,拿到的返回值是一个 list,而list里不能使用 contains 搜索test,contains只支持 string这类数据类型

上一页k8s网络下一页Jenkins Basic

最后更新于1年前