dockerfile-sec-1.0.0
توضیحات
Simple but powerful rules-based checker for Dockerfiles
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX |
| نام فایل | dockerfile-sec-1.0.0 |
| نام | dockerfile-sec |
| نسخه کتابخانه | 1.0.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Daniel Garcia (cr0hn) |
| ایمیل نویسنده | cr0hn@cr0hn.com |
| آدرس صفحه اصلی | https://github.com/cr0hn/dockerfile-security |
| آدرس اینترنتی | https://pypi.org/project/dockerfile-sec/ |
| مجوز | License :: OSI Approved :: BSD License |
# Dockerfile-sec
Dockerfile-sec is a simple but powerful rules-based checker for Dockerfiles.
## Install
```bash
> pip install dockerfile-sec
```
## Quick start
Analyze a Dockerfile
```bash
> dockerfile-sec examples/Dockerfile-example
+----------+-------------------------------------------+----------+
| Rule Id | Description | Severity |
+----------+-------------------------------------------+----------+
| core-001 | Missing content trust | Low |
| core-002 | Missing USER sentence in dockerfile | Medium |
| core-003 | Posible text plain password in dockerfile | High |
| core-005 | Recursive copy found | Medium |
| core-006 | Use of COPY instead of ADD | Low |
| core-007 | Use image tag instead of SHA256 hash | Medium |
| cred-001 | Generic credential | Medium |
| java-001 | Missing content trust | Low |
+----------+-------------------------------------------+----------+
```
## Usage
### With remote rules
```bash
> dockerfile-sec -r http://127.0.0.1:9999/rules/credentials.yaml Dockerfile
```
### With built-in rules
**All rules**
All rules are enabled by default:
```bash
> dockerfile-sec Dockerfile
```
**Core rules only**
https://github.com/cr0hn/dockerfile-security/blob/master/dockerfile_sec/rules/core.yaml
```bash
> dockerfile-sec -R core Dockerfile
```
**Java rules only**
https://github.com/cr0hn/dockerfile-security/blob/master/dockerfile_sec/rules/java.yaml
```bash
> dockerfile-sec -R java Dockerfile
```
**Credentials rules only**
https://github.com/cr0hn/dockerfile-security/blob/master/dockerfile_sec/rules/credentials.yaml
```bash
> dockerfile-sec -R credentials Dockerfile
```
**Disabling built-in rules**
```bash
> dockerfile-sec -R none Dockerfile
```
### With user defined rules
```bash
> dockerfile-sec -r my-rules.yaml Dockerfile
```
### With many user-defined rules files
```bash
> dockerfile-sec -r rules/java.yaml -r rules/credentials.yaml Dockerfile
```
### Export results as json
```bash
> dockerfile-sec -o results.json Dockerfile
```
### Quiet mode
Not writing anything in the console:
```bash
> dockerfile-sec -q -o results.json Dockerfile
```
### Filtering false positives
**By ignore file**
Dockerfile-sec allows to ignore rules by using a file that contains the rules you want to ignore.
```bash
> dockerfile-sec -F ignore-rules.text Dockerfile
```
Ignore file format contains the *IDs* of rules you want to ignore. **one ID per line**. Example:
```bash
> ls ignore-rules.text
core-001
core-007
```
**By using the cli**
You also can use cli to ignore specific *IDs*:
```bash
> dockerfile-sec -i core-001,core007 Dockerfile
```
## Using as a pipeline
You also can use dockerfile-sec as UNIX pipeline.
Loading Dockerfile from stdin:
```bash
> cat Dockerfile | dockerfile-sec -i core-001,core007
```
Exposing results via pipe:
```bash
> cat Dockerfile | dockerfile-sec -i core-001,core007 | jq
```
## Output formats
### JSON Output format
```json
[
{
"description": "Missing content trust",
"id": "core-001",
"reference": "https://snyk.io/blog/10-docker-image-security-best-practices/",
"severity": "Low"
},
{
"description": "Missing USER sentence in dockerfile",
"id": "core-002",
"reference": "https://snyk.io/blog/10-docker-image-security-best-practices/",
"severity": "Medium"
}
]
```
## References
- https://snyk.io/blog/10-docker-image-security-best-practices/
- https://medium.com/microscaling-systems/dockerfile-security-tuneup-166f1cdafea1
- https://medium.com/@tariq.m.islam/container-deployments-a-lesson-in-deterministic-ops-a4a467b14a03
نحوه نصب
نصب پکیج whl dockerfile-sec-1.0.0:
pip install dockerfile-sec-1.0.0.whl
نصب پکیج tar.gz dockerfile-sec-1.0.0:
pip install dockerfile-sec-1.0.0.tar.gz