Skip to content

Commit fa16690

Browse files
authored
feat(org): add sec-check command to assess organization security posture (#3142)
add sec-check command to assess organization security posture (#3142)
1 parent 235dddf commit fa16690

28 files changed

Lines changed: 1648 additions & 40 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Seed your space with example data.
1919
- Manage installation of [extensions](https://github.com/contentful/extensions) in a space.
2020
- Securely login and logout with our [OAuth service](https://www.contentful.com/developers/docs/references/authentication/).
21+
- Run organization security & configuration checks (security contact, audit logging, access tokens, SSO, MFA) with `contentful organization sec-check`.
2122
- Find all available commands in the [docs section](https://github.com/contentful/contentful-cli/tree/main/docs).
2223

2324
## :cloud: Installation

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Commands:
1111
init Get started with Contentful
1212
login Login to Contentful
1313
logout Logout from Contentful
14-
organization Manage and list your organizations
14+
organization Manage and list your organizations (includes security checks via `sec-check`)
1515
space Manage and list your spaces
1616

1717
Options:
@@ -29,5 +29,5 @@ Copyright Contentful 2019-Present
2929
- [init](./init) - Get an introduction to Contentful
3030
- [login](./login) - Start new CLI session
3131
- [logout](./logout) - End CLI session
32-
- [organization](./organization) - Organization related commands
32+
- [organization](./organization) - Organization related commands (security & configuration checks with `sec-check`)
3333
- [space](./space) - Space related commands

docs/organization/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
- [list](./list) - List all Organizations you have access to
66
- [export](./export) - Export a organization data to a json file
7+
- [sec-check](./sec-check) - Run organization security checks (audit-log, security contact, SSO, MFA)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Contentful CLI - `sec-check` command
2+
3+
This command runs a series of security checks on a Contentful Organization.
4+
5+
| Check | Description |
6+
|-------|-------------|
7+
| `permission_check` | Validates user has sufficient privileges (owner/admin) to perform security checks |
8+
| `security_contact_set` | Ensures ≥1 security contact is configured |
9+
| `audit_logging_configured` | Confirms audit logging is enabled |
10+
| `active_tokens_with_long_expiry` | Flags active access tokens whose expiration date is more than 1 year in the future |
11+
| `sso_enabled` | Validates SSO is enabled |
12+
| `sso_enforced` | Validates SSO restricted mode is on |
13+
| `sso_exempt_users` | Flags users exempt from SSO enforcement |
14+
| `sso_exempt_users_with_mfa_disabled` | Flags SSO-exempt users without MFA |
15+
16+
17+
## Usage
18+
```
19+
Usage: contentful organization sec-check --organization-id <organization-id>
20+
21+
Options:
22+
-h, --help Show help [boolean]
23+
--organization-id, --oid Contentful organization ID [string] [required]
24+
--management-token, --mt Contentful management API token (overrides stored
25+
context token) [string]
26+
--header, -H Pass an additional HTTP Header [string]
27+
--output-file, -o Write JSON results to a file. If used without a
28+
filename, a default file
29+
./data/<timestamp>-<org-id>-sec-check.json is
30+
created. [string]
31+
```
32+
33+
## Prerequisites
34+
- A Contentful Management API token with org admin/owner permissions to read organization settings.
35+
36+
37+
## Example
38+
39+
```
40+
contentful organization sec-check --organization-id 123456789 -o
41+
```
42+
43+
![img.png](img.png)
44+
45+
46+
Outputs JSON with fields:
47+
```
48+
{
49+
"permission_check": {
50+
"description": "User has owner or admin role in the organization",
51+
"pass": true
52+
},
53+
"security_contact_set": {
54+
"description": "Security contact is configured for the organization",
55+
"pass": true,
56+
"data": {
57+
"contactCount": 1
58+
}
59+
},
60+
"audit_logging_configured": {
61+
"description": "Audit logging is configured for the organization",
62+
"pass": true,
63+
"data": {
64+
"itemCount": 1
65+
}
66+
},
67+
"active_tokens_with_long_expiry": {
68+
"description": "Active (not revoked) access tokens whose expiration date is more than 1 year in the future.",
69+
"pass": false,
70+
"data": {
71+
"offendingCount": 6
72+
}
73+
},
74+
"sso_enabled": {
75+
"description": "SSO is enabled for the organization",
76+
"pass": true
77+
},
78+
"sso_enforced": {
79+
"description": "SSO is enforced (restricted) for the organization",
80+
"pass": true
81+
},
82+
"sso_exempt_users": {
83+
"description": "Check if users are exempted from SSO restricted mode (bypass SSO).",
84+
"pass": false,
85+
"data": {
86+
"exemptUserIds": [
87+
"2qEuWkv9GLQ8ypPK96xjZk"
88+
],
89+
"exemptCount": 1
90+
}
91+
},
92+
"sso_exempt_users_with_mfa_disabled": {
93+
"description": "Exempt users have MFA (2FA) enabled (reports users without MFA).",
94+
"pass": false,
95+
"data": {
96+
"mfaDisabledUsers": [
97+
{
98+
"id": "2qEuWkv9GLQ8ypPK96xjZk",
99+
"email": "hussam.khrais+test@foo.com"
100+
}
101+
],
102+
"mfaDisabledCount": 1
103+
}
104+
}
105+
}
106+
```
107+
A check with pass:false indicates action required.
165 KB
Loading

0 commit comments

Comments
 (0)