Preprocesses SCPs.
Project description
Service Control Policy (SCP) preprocessor
A command line tool that takes a single JSON file and outputs a collection of valid service control policies. This allows you to organize your SCPs logically and write statements in a way that makes sense to you without directly worrying about size constraints. The tool will then handle optimization and bin packing of your single JSON file into a collection of SCPs that fit the size limits. The tool also introduces some new SCP language concepts that are explained below.
The resultant SCPs are written to std out as an array of SCPs.
Getting Started
Installation:
Python 3.6+ is supported.
pip install service-control-policy-preprocessor
Basic usage:
scp-pre process file://my-single-scp > output.json
Available Commands
process
scp-pre process file://my-single-scp.json
| Arguments | Description |
|---|---|
| --enable-logging | Enables log output to stdout. Turn off if you want to use the SCP output which is also output to stdout. |
| --retain-sid | Retain the SID element of the policy in the SCP output |
| --basic | Basic transformation. Skips the wildcarding of IAM actions that outputs the shortest possible action prefix to save space. |
| --pretty-print | Keep whitespace to make output readable. Useful for debugging. |
New language constructs for IAM actions
Exclude a particular action from the resulting action list
Must be an exact action name, does not support globbing. Useful when there are only a few exemptions.
Example:
{
...
"Action": [
"iam:*User*",
"iam:{Exclude:ListUsers}"
]
}
Resulting SCP will contain all actions matching iam:*User* except for iam:ListUsers.
Adds support for wildcards in all parts of IAM action name
Example:
{
...
"Action": [
"service:*PartOfActionName*"
]
}
Regular SCP syntax only supports wildcards at the end of the action name. The resulting SCP will have all actions that match this wildcard pattern expanded.
Adds support for comment element in SCPs
Example:
{
...
"Action": [
"service:Action"
],
"Comment": "This will be stripped off before deployment, but can be helpful when left in a source repository."
}
Comments are stripped during preproccessing. This is a helpful place to store a short explanation of the policy statement.
Transformations that are done to your SCP (in order)
- SIDs and Comments are removed from all statements
- Wildcards are expanded
- Actions are excluded if using the {Exclude} syntax
- Statements with the same Effect, Resource, and Condition are merged together
- Actions are wildcarded to save space. This can be disabled with the
--basicflag.- Example: iam:SetSecurityTokenServicePreferences -> iam:SetS*
- You will want to run this transformation periodically (e.g. daily) if you use this feature. This is because new IAM actions are added over time that the transformation has not taken into account when shortening these action names.
- Statements are bin packed to fit SCP size quotas
Security
See CONTRIBUTING for more information.
License
This library is licensed under the MIT-0 License. See the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file service_control_policy_preprocessor-0.0.2.tar.gz.
File metadata
- Download URL: service_control_policy_preprocessor-0.0.2.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e4ca1527d96a7c63167dd3dad28fe8aaed068f9c73e8bc9ecc93b90d30f25c9
|
|
| MD5 |
43f3b0836de2f70930569c3c984ae410
|
|
| BLAKE2b-256 |
071e94f49fd1dba8b10a09bd6d4589e31543747f2067b58d645a1971f86d4f19
|
Provenance
The following attestation bundles were made for service_control_policy_preprocessor-0.0.2.tar.gz:
Publisher:
release-to-pypi.yaml on aws-samples/service-control-policy-preprocessor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
service_control_policy_preprocessor-0.0.2.tar.gz -
Subject digest:
6e4ca1527d96a7c63167dd3dad28fe8aaed068f9c73e8bc9ecc93b90d30f25c9 - Sigstore transparency entry: 495313434
- Sigstore integration time:
-
Permalink:
aws-samples/service-control-policy-preprocessor@9819e9b8b96f4a59fd05f224ae0bff4badcc65a5 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/aws-samples
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-to-pypi.yaml@9819e9b8b96f4a59fd05f224ae0bff4badcc65a5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file service_control_policy_preprocessor-0.0.2-py3-none-any.whl.
File metadata
- Download URL: service_control_policy_preprocessor-0.0.2-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5fa082334cb7ff59cfec39d8252cb3b87b2004c3eaeaff98b7d39d5d9405b32
|
|
| MD5 |
9d3f7dc451efd89fc5ccb4b5fe216b12
|
|
| BLAKE2b-256 |
44e1310dd9ff0c3e28e2af8cae2c2f6fc5cab09a50591b3116f3ed8eb77f7e7f
|
Provenance
The following attestation bundles were made for service_control_policy_preprocessor-0.0.2-py3-none-any.whl:
Publisher:
release-to-pypi.yaml on aws-samples/service-control-policy-preprocessor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
service_control_policy_preprocessor-0.0.2-py3-none-any.whl -
Subject digest:
e5fa082334cb7ff59cfec39d8252cb3b87b2004c3eaeaff98b7d39d5d9405b32 - Sigstore transparency entry: 495313459
- Sigstore integration time:
-
Permalink:
aws-samples/service-control-policy-preprocessor@9819e9b8b96f4a59fd05f224ae0bff4badcc65a5 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/aws-samples
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-to-pypi.yaml@9819e9b8b96f4a59fd05f224ae0bff4badcc65a5 -
Trigger Event:
release
-
Statement type: