TMAegisБета
Више правила за oci

Oracle Cloud Infrastructure

TMA-OCI-1.8

Ensure user API keys rotate within 90 days

ВисокаНиво 1Аутоматскаoci

Опис

API keys are used by administrators, developers, services and scripts for accessing OCI APIs directly or via SDKs/OCI CLI to search, create, update or delete OCI resources. The API key is an RSA key pair. It is important to secure and rotate an API key every 90 days or less as it provides the same level of access that a user it is associated with has. No ACTIVE user may hold a API key created more than 90 days ago (users of the Default identity domain, as listed by oci iam user list). Read-only OCI CLI calls; credentials and home region come from the CLI's normal configuration (~/.oci/config, OCI_CLI_PROFILE, OCI_CLI_AUTH). The tenancy OCID is taken from OCI_TENANCY or the first tenancy= line of the config file. A missing CLI or credential fails the check.

Како се проверава

Метод провере: Команда љуске

shell
t=${OCI_TENANCY:-$(sed -n 's/^[[:space:]]*tenancy[[:space:]]*=[[:space:]]*//p' "${OCI_CLI_CONFIG_FILE:-$HOME/.oci/config}" 2>/dev/null | head -n 1 | tr -d '\r[:space:]')}
[ -n "$t" ] || exit 1
bad=0
cutoff=$(date -u -d '90 days ago' +%Y-%m-%dT%H:%M:%S 2>/dev/null || date -u -v-90d +%Y-%m-%dT%H:%M:%S 2>/dev/null) || exit 1
us=$(oci iam user list --compartment-id "$t" --all --query 'data[?"lifecycle-state"==`"ACTIVE"`].id' --raw-output 2>/dev/null) || exit 1
for u in $(printf '%s\n' "$us" | grep -o 'ocid1\.user\.[^"]*'); do
  ks=$(oci iam user api-key list --user-id "$u" --query 'data[?"lifecycle-state"==`"ACTIVE"`]."time-created"' --raw-output 2>/dev/null) || exit 1
  old=$(printf '%s\n' "$ks" | grep -o '"[0-9][^"]*"' | tr -d '"' | awk -v c="$cutoff" '$1 < c')
  [ -z "$old" ] || { echo "API key older than 90 days: $u"; bad=1; }
done
[ "$bad" -eq 0 ] && echo compliant
Очекивани излаз
compliant

Како се исправља

Метод исправке: Смерница или закрпа инфраструктуре

Upload a new API key for each listed user (oci iam user api-key upload), move clients to it, then oci iam user api-key delete --user-id <ocid> --fingerprint <old>.

Својства

Оперативни системи
Било који
Ознаке
ociiam
Референца
CIS Oracle Cloud Infrastructure Foundations Benchmark v3.1.1 - 1.8 Ensure user API keys rotate within 90 days

Проверите овај рачунар

Покрените ово на рачунару за који имате дозволу за проверу. Скенирање ради у режиму само за читање.

shell
tmaegis scan --target oci