id: issue-file-permissions-check

info:
  name: Ensure Access to /etc/issue is Configured
  author: Th3l0newolf
  severity: medium
  description: |
    This template checks whether /etc/issue has secure ownership and permissions.
  remediation: |
    Set the ownership and permissions on `/etc/issue`:
      sudo chown root:root /etc/issue
      sudo chmod 644 /etc/issue
  reference:
    - https://www.cisecurity.org/benchmark/ubuntu_linux
  tags: cis,linux,ubuntu,issue,permissions,audit
  metadata:
    verified: true

self-contained: true

code:
  - engine:
      - bash
    args:
      - "-c"
      - |
        mode=$(stat -Lc "%a" /etc/issue)
        uid=$(stat -Lc "%u" /etc/issue)
        gid=$(stat -Lc "%g" /etc/issue)

        if [ "$uid" -eq 0 ] && [ "$gid" -eq 0 ] && [ "$mode" -le 644 ]; then
          echo "[issue-file-permissions-check:Policy-Pass] [/etc/issue ownership and permissions are correctly configured] [CIS_PASS] [medium]"
        else
          echo "[issue-file-permissions-check:Policy-Fail] [/etc/issue ownership or permissions are incorrectly configured] [CIS_FAIL] [medium]"
        fi

    matchers:
      - type: word
        name: policy-pass
        words:
          - "Policy-Pass"

      - type: word
        name: policy-fail
        words:
          - "Policy-Fail"
# digest: 4a0a0047304502204805f23b5b2fde38972210068588544f6d63ee85808fd260c1110d3bf74e0f81022100bcf8c34f4972f68f33fcbe9e00e7a9d4d88db7c5fbd44edc9015fdd09435e104:922c64590222798bb761d5b6d8e72950