-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
aliases: | ||
- /continuous_integration/static_analysis/circleci_orbs | ||
dependencies: | ||
- https://github.com/DataDog/datadog-static-analyzer-circleci-orb/blob/main/README.md | ||
description: Use Datadog and CircleCI to run Static Analysis jobs in a CI pipeline. | ||
kind: documentation | ||
title: Static Analysis and CircleCI Orbs | ||
--- | ||
[![CircleCI Build Status](https://circleci.com/gh/DataDog/datadog-static-analyzer-circleci-orb.svg?style=shield "CircleCI Build Status")](https://circleci.com/gh/DataDog/datadog-static-analyzer-circleci-orb) [![CircleCI Orb Version](https://badges.circleci.com/orbs/DataDog/datadog-static-analyzer-circleci-orb.svg)](https://circleci.com/developer/orbs/orb/DataDog/datadog-static-analyzer-circleci-orb) [![GitHub License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/DataDog/datadog-static-analyzer-circleci-orb/main/LICENSE) [![CircleCI Community](https://img.shields.io/badge/community-CircleCI%20Discuss-343434.svg)](https://discuss.circleci.com/c/ecosystem/orbs) | ||
|
||
|
||
Run a Datadog Static Analysis in your CircleCI workflows. | ||
|
||
## Requirements | ||
|
||
To use the Datadog static analyzer, you need to add a `static-analysis.datadog.yml` file to your repositories root directory that specifies what rulesets to use. | ||
|
||
```yaml | ||
rulesets: | ||
- <ruleset-name> | ||
- <ruleset-name> | ||
``` | ||
#### Example for Python | ||
You can see an example for repositories based on Python: | ||
```yaml | ||
rulesets: | ||
- python-security | ||
- python-code-style | ||
- python-best-practices | ||
``` | ||
## Workflow | ||
Create a file in `.circleci` to run a Datadog static analysis. | ||
|
||
Here's a sample workflow file. | ||
|
||
```yaml | ||
version: 2.1 | ||
orbs: | ||
datadog-static-analysis: datadog/datadog-static-analyzer-circleci-orb@1.0.0 | ||
jobs: | ||
run-static-analysis-job: | ||
docker: | ||
- image: cimg/node:current | ||
steps: | ||
- checkout | ||
- datadog-static-analysis/analyze: | ||
service: my-service | ||
workflows: | ||
main: | ||
jobs: | ||
- run-static-analysis-job | ||
``` | ||
|
||
## Environment Variables | ||
|
||
These environment variables should be set in the [CircleCI Project Settings](https://circleci.com/docs/set-environment-variable/#set-an-environment-variable-in-a-project) page. | ||
|
||
| Name | Description | Required | Default | | ||
|--------------|----------------------------------------------------------------------------------------------------------------------------|----------|-----------------| | ||
| `DD_API_KEY` | Your Datadog API key. This key is created by your [Datadog organization](https://docs.datadoghq.com/account_management/api-app-keys/#api-keys) and should be stored as a secret. | True | | | ||
| `DD_APP_KEY` | Your Datadog Application key. This key is created by your [Datadog organization](https://docs.datadoghq.com/account_management/api-app-keys/) and should be stored as a secret. | True | | | ||
|
||
## Inputs | ||
|
||
To customize your workflow, you can set the following parameters for an analysis. | ||
|
||
| Name | Description | Required | Default | | ||
|--------------|----------------------------------------------------------------------------------------------------------------------------|----------|-----------------| | ||
| `service` | The service you want your results tagged with. | True | | | ||
| `env` | The environment you want your results tagged with. | False | `none` | | ||
| `site` | The [Datadog site](https://docs.datadoghq.com/getting_started/site/) | False | `datadoghq.com` | | ||
|
||
## Resources | ||
|
||
[CircleCI Orb Registry Page](https://circleci.com/developer/orbs/orb/DataDog/datadog-static-analyzer-circleci-orb) - The official registry page of this orb for all versions, executors, commands, and jobs described. | ||
|
||
[CircleCI Orb Docs](https://circleci.com/docs/orb-intro/#section=configuration) - Docs for using, creating, and publishing CircleCI Orbs. | ||
|
||
### How to Contribute | ||
|
||
We welcome [issues](https://github.com/DataDog/datadog-static-analyzer-circleci-orb/issues) to and [pull requests](https://github.com/DataDog/datadog-static-analyzer-circleci-orb/pulls) against this repository! | ||
|
||
### How to Publish An Update | ||
1. Merge pull requests with desired changes to the main branch. | ||
- For the best experience, squash-and-merge and use [Conventional Commit Messages](https://conventionalcommits.org/). | ||
2. Find the current version of the orb. | ||
- You can run `circleci orb info DataDog/datadog-static-analyzer-circleci-orb | grep "Latest"` to see the current version. | ||
3. Create a [new Release](https://github.com/DataDog/datadog-static-analyzer-circleci-orb/releases/new) on GitHub. | ||
- Click "Choose a tag" and _create_ a new [semantically versioned](http://semver.org/) tag. (ex: v1.0.0) | ||
- We will have an opportunity to change this before we publish if needed after the next step. | ||
4. Click _"+ Auto-generate release notes"_. | ||
- This will create a summary of all of the merged pull requests since the previous release. | ||
- If you have used _[Conventional Commit Messages](https://conventionalcommits.org/)_ it will be easy to determine what types of changes were made, allowing you to ensure the correct version tag is being published. | ||
5. Now ensure the version tag selected is semantically accurate based on the changes included. | ||
6. Click _"Publish Release"_. | ||
- This will push a new tag and trigger your publishing pipeline on CircleCI. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
aliases: | ||
- /continuous_integration/static_analysis/github_actions | ||
dependencies: | ||
- https://github.com/DataDog/datadog-static-analyzer-github-action/blob/main/README.md | ||
description: Use Datadog and GitHub to run Static Analysis jobs in a CI pipeline. | ||
kind: documentation | ||
title: Static Analysis and GitHub Actions | ||
--- | ||
Run a Datadog Static Analysis in your Github Action workflows. | ||
|
||
## Requirements | ||
|
||
To use the Datadog static analyzer, you need to add a `static-analysis.datadog.yml` file to your repositories root directory that specifies what rulesets to use. | ||
|
||
```yaml | ||
rulesets: | ||
- <ruleset-name> | ||
- <ruleset-name> | ||
``` | ||
#### Example for Python | ||
You can see an example for repositories based on Python: | ||
```yaml | ||
rulesets: | ||
- python-security | ||
- python-code-style | ||
- python-best-practices | ||
``` | ||
## Workflow | ||
Create a file in `.github/workflows` to run a Datadog static analysis. | ||
|
||
Here's a sample workflow file. | ||
|
||
```yaml | ||
on: [push] | ||
jobs: | ||
check-quality: | ||
runs-on: ubuntu-latest | ||
name: Datadog Static Analyzer | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Check code meets quality standards | ||
id: datadog-static-analysis | ||
uses: DataDog/datadog-static-analyzer-github-action@v1.0.0 | ||
with: | ||
dd_app_key: ${{ secrets.DD_APP_KEY }} | ||
dd_api_key: ${{ secrets.DD_API_KEY }} | ||
dd_service: "my-service" | ||
dd_env: "ci" | ||
``` | ||
|
||
> You **must** set your Datadog API and Application Keys as secrets in your GitHub repository. For more information, see [API and Application Keys][1] | ||
|
||
## Inputs | ||
|
||
| Name | Description | Required | Default | | ||
|--------------|----------------------------------------------------------------------------------------------------------------------------|----------|-----------------| | ||
| `dd_api_key` | Your Datadog API key. This key is created by your [Datadog organization][1] and should be stored as a [secret][2]. | True | | | ||
| `dd_app_key` | Your Datadog Application key. This key is created by your [Datadog organization][1] and should be stored as a [secret][2]. | True | | | ||
| `dd_service` | The service you want your results tagged with. | True | | | ||
| `dd_env` | The environment you want your results tagged with. | False | `none` | | ||
| `dd_site` | The [Datadog site](https://docs.datadoghq.com/getting_started/site/) | False | `datadoghq.com` | | ||
|
||
[1]: https://docs.datadoghq.com/account_management/api-app-keys/ | ||
[2]: https://docs.github.com/en/actions/security-guides/encrypted-secrets |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
dependencies: [] | ||
disable_edit: true | ||
kind: documentation | ||
meta: | ||
category: Best Practices | ||
id: docker-best-practices/absolute-workdir | ||
language: Docker | ||
severity: Warning | ||
title: Use absolute workdir | ||
--- | ||
## Metadata | ||
**ID:** `docker-best-practices/absolute-workdir` | ||
|
||
**Language:** Docker | ||
|
||
**Severity:** Warning | ||
|
||
**Category:** Best Practices | ||
|
||
## Description | ||
When using a relative `WORKDIR`, you may run into problems since you are dependent on previous `WORKDIR` instructions. Using an absolute `WORKDIR` ensures you have the right path no matter where the instruction is positioned. | ||
|
||
## Non-Compliant Code Examples | ||
Check warning on line 24 in content/en/static_analysis/rules/docker-best-practices/absolute-workdir.md GitHub Actions / vale[vale] content/en/static_analysis/rules/docker-best-practices/absolute-workdir.md#L24
Raw output
|
||
```docker | ||
FROM busybox | ||
WORKDIR usr/src/app | ||
``` | ||
|
||
## Compliant Code Examples | ||
Check warning on line 30 in content/en/static_analysis/rules/docker-best-practices/absolute-workdir.md GitHub Actions / vale[vale] content/en/static_analysis/rules/docker-best-practices/absolute-workdir.md#L30
Raw output
|
||
```docker | ||
FROM busybox | ||
WORKDIR /usr/src/app | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
dependencies: [] | ||
disable_edit: true | ||
kind: documentation | ||
meta: | ||
category: Error Prone | ||
id: docker-best-practices/alias-must-be-unique | ||
language: Docker | ||
severity: Warning | ||
title: FROM aliases must be unique | ||
--- | ||
## Metadata | ||
**ID:** `docker-best-practices/alias-must-be-unique` | ||
|
||
**Language:** Docker | ||
|
||
**Severity:** Warning | ||
|
||
**Category:** Error Prone | ||
|
||
## Description | ||
When using multiple images in a Dockerfile, aliases must be unique. | ||
|
||
## Non-Compliant Code Examples | ||
Check warning on line 24 in content/en/static_analysis/rules/docker-best-practices/alias-must-be-unique.md GitHub Actions / vale[vale] content/en/static_analysis/rules/docker-best-practices/alias-must-be-unique.md#L24
Raw output
|
||
```docker | ||
FROM awesomeimage:version as build | ||
RUN stuff | ||
FROM otherawesomeimage:version1 as foobar | ||
RUN plop | ||
FROM otherawesomeimage:version2 as build | ||
RUN more_stuff | ||
``` | ||
|
||
## Compliant Code Examples | ||
Check warning on line 34 in content/en/static_analysis/rules/docker-best-practices/alias-must-be-unique.md GitHub Actions / vale[vale] content/en/static_analysis/rules/docker-best-practices/alias-must-be-unique.md#L34
Raw output
|
||
```docker | ||
FROM awesomeimage:version as build | ||
RUN stuff | ||
FROM otherawesomeimage:version as another-alias | ||
RUN more_stuff | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
dependencies: [] | ||
disable_edit: true | ||
kind: documentation | ||
meta: | ||
category: Best Practices | ||
id: docker-best-practices/apt-get-yes | ||
language: Docker | ||
severity: Warning | ||
title: Always use -y with apt-get install | ||
--- | ||
## Metadata | ||
**ID:** `docker-best-practices/apt-get-yes` | ||
|
||
**Language:** Docker | ||
|
||
**Severity:** Warning | ||
|
||
**Category:** Best Practices | ||
|
||
## Description | ||
When using `apt-get` to install a package, make sure you use the `-y` flag to avoid your CI being blocked on a prompt. | ||
|
||
## Non-Compliant Code Examples | ||
Check warning on line 24 in content/en/static_analysis/rules/docker-best-practices/apt-get-yes.md GitHub Actions / vale[vale] content/en/static_analysis/rules/docker-best-practices/apt-get-yes.md#L24
Raw output
|
||
```docker | ||
RUN apt-get install gcc | ||
``` | ||
|
||
## Compliant Code Examples | ||
Check warning on line 29 in content/en/static_analysis/rules/docker-best-practices/apt-get-yes.md GitHub Actions / vale[vale] content/en/static_analysis/rules/docker-best-practices/apt-get-yes.md#L29
Raw output
|
||
```docker | ||
RUN apt-get install -y gcc | ||
``` |