규칙 생성

규칙 생성 (Create rule)

POST /orgs/{org_name}/governance/policies/{policy_id}/rules — 정책의 규칙 세트에 규칙을 추가해요. 정책의 모든 규칙은 같은 도메인(network 또는 filesystem)을 공유해야 하며, 도메인 혼합은 거부돼요.

출처: 문서

본문

API 버전 1 — Create rule · POST /orgs/{org_name}/governance/policies/{policy_id}/rules

정책의 규칙 세트에 규칙을 추가해요. 정책의 모든 규칙은 같은 도메인(network 또는 filesystem)을 공유해야 하며, 도메인 혼합은 거부돼요.

Network 액션: connect:tcp, connect:udp. 리소스는 호스트 이름(예: example.com), 와일드카드 서브도메인(*.example.com은 한 단계, **.example.com은 모든 깊이), 선택적 포트가 있는 호스트 이름(예: example.com:443), 또는 IPv4·IPv6 표기의 CIDR(예: 10.0.0.0/8 또는 2001:db8::/32)이에요.

Filesystem 액션: read, write. 리소스는 경로(예: /data)예요. 단일 경로 세그먼트 안에서 매치하려면 *를, 세그먼트를 가로질러 재귀적으로 매치하려면 **를 사용해요(예: /data/**).

변경 사항은 개발자 머신에 도달하는 데 최대 5분이 걸릴 수 있어요.

연결 및 접근 (Connection and access)

API 연결 및 인증 안내

https://hub.docker.com/v2

다음 대안 중 하나를 사용해요. 한 대안 안의 요구 사항은 함께 적용돼요.

  • bearerAuth

파라미터

org_name

path · 필수 — Docker Hub 조직 이름. 유형: string

{
  "type": "string"
}

policy_id

path · 필수 — 고유 정책 식별자. 유형: string

{
  "type": "string"
}

요청 및 응답

Media type: application/json

요청 (Request)

액션, 리소스, 결정을 포함한 규칙 정의.

스키마: CreateRuleRequest

filesystem:

{
  "actions": [
    "read",
    "write"
  ],
  "decision": "allow",
  "name": "allow data directory",
  "resources": [
    "/data"
  ]
}

network:

{
  "actions": [
    "connect:tcp",
    "connect:udp"
  ],
  "decision": "allow",
  "name": "allow research mirrors",
  "resources": [
    "research.mitre.org",
    "cve.mitre.org"
  ]
}

응답 201

규칙이 생성되어 정책의 규칙 세트에 추가됨.

스키마: Rule

filesystem:

{
  "actions": [
    "read",
    "write"
  ],
  "decision": "allow",
  "id": "rule_07fwtnr0kn2qetl1b9olfbyz8kob",
  "name": "allow data directory",
  "resources": [
    "/data"
  ]
}

network:

{
  "actions": [
    "connect:tcp",
    "connect:udp"
  ],
  "decision": "allow",
  "id": "rule_06evsm9qjm1pdsk0a8nkfaxy7jna",
  "name": "allow research mirrors",
  "resources": [
    "research.mitre.org",
    "cve.mitre.org"
  ]
}

응답 400

Bad request · 스키마: Error

{
  "error": {
    "code": "invalid_argument",
    "message": "name is required"
  }
}

응답 401

Missing or invalid credentials · 스키마: Error

{
  "error": {
    "code": "unauthenticated",
    "message": "unauthenticated"
  }
}

응답 403

호출자가 이 조직에 대한 필수 권한이 없거나, 조직이 governance를 사용할 자격이 없거나(permission_denied), 생성 한도에 도달했을 때(limit_exceeded). 스키마: Error

limit_exceeded:

{
  "error": {
    "code": "limit_exceeded",
    "message": "organization has reached the maximum of 100 policies"
  }
}

permission_denied:

{
  "error": {
    "code": "permission_denied",
    "message": "permission denied"
  }
}

응답 404

Not found · 스키마: Error

{
  "error": {
    "code": "not_found",
    "message": "policy not found"
  }
}

응답 409

Conflict · 스키마: Error

{
  "error": {
    "code": "conflict",
    "message": "policy name already in use"
  }
}

응답 500

Internal server error · 스키마: Error

{
  "error": {
    "code": "internal",
    "message": "internal error"
  }
}

참조 스키마

  • #/components/schemas/CreateRuleRequest
  • #/components/schemas/Rule

요청 예시

curl \
  --request POST \
  --header "Authorization: Bearer ***" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "actions": [
    "read",
    "write"
  ],
  "decision": "allow",
  "name": "allow data directory",
  "resources": [
    "/data"
  ]
}' \
  'https://hub.docker.com/v2/orgs//governance/policies//rules'

더 알아보기 (Learn more)