Skip to content

Security Group Rules and Driver API

ByoungSeob Kim edited this page Apr 5, 2022 · 47 revisions

1. CB-Spider Security Group and Rules

  • VM의 in/out 네트워크 트래픽 제어를 위해서 특정 VPC에 소속되는 Security Group을 정의할 수 있다.

  • Security Group은 하나 이상의 규칙을 포함할 수 있으며, 허용 규칙을 정의한다. (Allow Rule)

  • Security Group 생성 시에는 최소 1개 이상의 Rule을 포함해야 하며, 이후 Rule을 추가 삭제할 수 있다.

  • Security Group 생성 시 default Rule은 다음과 같고, CSP별로 관련 Rule이 보일 수도 있고 안보일 수도 있다.

    • inbound: 모든 트래픽 차단
    • outbound: 모든 트래픽 허용
  • Rule은 다음과 같은 속성들로 정의할 수 있다.

    • Direction: 트래픽 방향
      • inbound | outbound
    • Protocol: 대상 프로토콜
      • ALL: 모든 트래픽 허용
      • TCP | UDP | ICMP
    • Port Range: 대상 포트 범위
      • FromPort: 22, ToPort: 22
      • FromPort: 1, ToPort: 65535
      • FromPort: -1, ToPort: -1: 포트 설정이 무의미, 또는 모든 포트 대상
    • Source or Destination: 적용 대상, Address CIDR Block으로 표현
      • 0.0.0.0/0, ::/0, 1.2.3.4/32, ...
  • CSP Driver 개발 가이드

    • Security Group 생성시 대상 CSP의 default Rule 규칙 확인
      • Spider default rule과 다를 경우 Spider default rule로 설정 필요
    • ALL, -1 관련: 대상 CSP에서 Spider와 의미가 다를 경우 변환 처리 필요
      • ex) ALL <---> ANY
  • Rule's Data Structure 참고

    type SecurityRuleInfo struct {
          Direction  string
          IPProtocol string
          FromPort   string
          ToPort     string
          CIDR       string
    }
  • 프로토콜별 Rule 세부 규칙 참고

    Direction IPProtocol FromPort ToPort CIDR Block (source or destination) 비고
    inbound, outbound ALL -1 -1 IPv4 ex) 0.0.0.0/0
    IPv6 ex) ::/0
    * ALL: All traffic
    inbound, outbound TCP 1~65535
    ex) 443
    1~65535
    ex) 443
    IPv4 ex) 0.0.0.0/8
    IPv6 ex) ::/8
    inbound, outbound UDP 1~65535
    ex) 6000
    1~65535
    ex) 8000
    IPv4 ex) 0.0.0.0/32
    IPv6 ex) ::/32
    inbound, outbound ICMP -1 -1 IPv4 ex) 1.2.3.4/32
    IPv6 ex) ::/64
    * ICMP: network layer
    - Port 지정 불필요
    - ICMP 예시: ping, echo, tracert 등
  • CSP별 Security Group Rule 참고

2. Security Group 기능 개선

  • 생성한 Security Group에 Rule 추가/삭제 기능 추가
  • AddRules(), RemoveRules() API 신규 추가

2.1. AS-IS

type SecurityReqInfo struct {
        IId IID // {NameId, SystemId}

        VpcIID        IID    // {NameId, SystemId}
        Direction     string // To be deprecated
        SecurityRules *[]SecurityRuleInfo
}

type SecurityRuleInfo struct {
        Direction  string
        IPProtocol string
        FromPort   string
        ToPort     string
        CIDR       string
}

type SecurityInfo struct {
        IId IID // {NameId, SystemId}

        VpcIID        IID    // {NameId, SystemId}
        Direction     string // To be deprecated
        SecurityRules *[]SecurityRuleInfo

        KeyValueList []KeyValue
}

type SecurityHandler interface {
        CreateSecurity(securityReqInfo SecurityReqInfo) (SecurityInfo, error)
        ListSecurity() ([]*SecurityInfo, error)
        GetSecurity(securityIID IID) (SecurityInfo, error)
        DeleteSecurity(securityIID IID) (bool, error)
}

2.2. TO-BE

type SecurityReqInfo struct {
        IId IID // {NameId, SystemId}

        VpcIID        IID    // {NameId, SystemId}
        //Direction     string // To be deprecated                            <=== Deleted
        SecurityRules *[]SecurityRuleInfo
}

type SecurityRuleInfo struct {
        Direction  string
        IPProtocol string
        FromPort   string
        ToPort     string
        CIDR       string
}

type SecurityInfo struct {
        IId IID // {NameId, SystemId}

        VpcIID        IID    // {NameId, SystemId}
        //Direction     string // To be deprecated                            <=== Deleted
        SecurityRules *[]SecurityRuleInfo

        KeyValueList []KeyValue
}

type SecurityHandler interface {
        CreateSecurity(securityReqInfo SecurityReqInfo) (SecurityInfo, error)
        ListSecurity() ([]*SecurityInfo, error)
        GetSecurity(securityIID IID) (SecurityInfo, error)
        DeleteSecurity(securityIID IID) (bool, error)

        AddRules(sgIID IID, securityRules *[]SecurityRulesInfo) (SecurityInfo, error)                 <==== Added
        RemoveRules(sgIID IID, securityRules *[]SecurityRulesInfo) (bool, error)                      <==== Added
}

2.3. Note

  • SecurityReqInfo.DirectionSecurityInfo.Direction 삭제 예정
    • AdminWeb, Test Scripts, Driver/Test, Tumblebug/Test 등 사용 여부 파악 필요
    • 현황 파악 후 현 작업시 삭제 여부 결정 예정

2.4. SG 관련 이슈 및 참고 사항


3. 주요 Test Cases (TBD)

3.1. inbound Test Cases

  • Security Group으로 생성된 대상 VM을 향한 Test

  • CASE-1: default inbound test

    • Test Command
      nc -w 2 -zv {$VM_IP} 22
      
      • Expected Results
      Connection to {$VM_IP} port [tcp/http] succeeded!
      
  • WIP

3.2. Outbound Test Cases

  • 이후 생성된 대상 VM에 로그인 후 Test

  • CASE-1: default outbound test

    • Test Command
      nc -w 2 -zv 142.250.190.99 80
      
      • Expected Results
      Connection to 142.250.190.99 80 port [tcp/http] succeeded!
      
  • CASE-2: remove default outbound test

    • 설정: remove default rule (outbound TCP 80 80 0.0.0.0/0)
    • Test Command
      nc -w 2 -zv 142.250.190.99 80
      
      • Expected Results
      nc: connect to 142.250.190.99 port 80 (tcp) timed out: Operation now in progress
      
  • CASE-3: add outbound 80 port test

    • 설정: add rule (outbound TCP 80 80 0.0.0.0/0)
    • Test Command
      nc -w 2 -zv 142.250.190.99 80
      
      • Expected Results
      Connection to 142.250.190.99 80 port [tcp/http] succeeded!
      

Table of contents



Clone this wiki locally