TMAegis베타
alibaba 관련 규칙 더 보기

Alibaba Cloud

TMA-ALIBABA-6.8

Ensure server parameter 'log_disconnections' is set to 'ON' for PostgreSQL Database Server

보통레벨 1자동alibaba

설명

Enable log_disconnections on PostgreSQL Servers. Enabling log_disconnections helps PostgreSQL Database to log session terminations of the server, as well as duration of the session. Log data can be used to identify, troubleshoot, and repair configuration errors and ... For every PostgreSQL instance the running parameter log_disconnections must be on. Iterates every RDS region and instance (DescribeDBInstances). Read-only aliyun CLI calls; credentials and default region come from the CLI's normal profile (aliyun configure, ~/.aliyun/config.json or ALIBABA_CLOUD_* environment variables). JSON output is parsed with sed/awk. A missing CLI or credential fails the check.

점검 방법

감사 방식: 셸 명령

shell
regs=$(aliyun rds DescribeRegions 2>/dev/null) || exit 1
regions=$(printf '%s\n' "$regs" | sed -n 's/.*"RegionId"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | sort -u)
[ -n "$regions" ] || exit 1
bad=0
for r in $regions; do
  page=1
  while :; do
    out=$(aliyun rds DescribeDBInstances --RegionId "$r" --Engine PostgreSQL --PageSize 100 --PageNumber "$page" 2>/dev/null) || exit 1
    ids=$(printf '%s\n' "$out" | sed -n 's/.*"DBInstanceId"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | sort -u)
    [ -n "$ids" ] || break
    for i in $ids; do
      p=$(aliyun rds DescribeParameters --DBInstanceId "$i" 2>/dev/null) || exit 1
      v=$(printf '%s\n' "$p" | awk '
/\{/ { nm = ""; vl = "" }
/"ParameterName"/ { nm = $0; sub(/^[^:]*:[[:space:]]*"/, "", nm); sub(/".*/, "", nm) }
/"ParameterValue"/ { vl = $0; sub(/^[^:]*:[[:space:]]*"/, "", vl); sub(/".*/, "", vl) }
/\}/ { if (nm == "log_disconnections") { print tolower(vl); exit } }')
      [ "$v" = on ] || { echo "log_disconnections=${v:-unset}: $r $i"; bad=1; }
    done
    set -- $ids
    [ "$#" -lt 100 ] && break
    page=$((page + 1))
  done
done
[ "$bad" -eq 0 ] && echo compliant
예상 출력
compliant

조치 방법

조치 방식: 가이드 또는 인프라 패치

aliyun rds ModifyParameter --DBInstanceId <id> --Parameters '{"log_disconnections":"on"}' (RDS console > Parameters), then confirm the running value.

속성

운영 체제
모두
태그
alibabards
참고 자료
CIS Alibaba Cloud Foundation Benchmark v2.0.1 - 6.8 Ensure server parameter 'log_disconnections' is set to 'ON' for PostgreSQL Database Server

이 호스트 점검하기

감사 권한이 있는 시스템에서 실행하세요. 스캔은 읽기 전용입니다.

shell
tmaegis scan --target alibaba