Skip to content

Commit 1a88932

Browse files
clean up linter complaints
1 parent 4586818 commit 1a88932

File tree

1 file changed

+71
-36
lines changed

1 file changed

+71
-36
lines changed

README.md

Lines changed: 71 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ The following methods can be used to schedule a scan:
2727
* A project is assigned to one or more groups with a configured group schedule.
2828
* A default schedule is defined and the project is not configured for a scheduled scan via any other method.
2929

30-
3130
### Scheduling via Tags
3231

3332
This is the preferred method of scheduling scans. Scheduling a project for
3433
scanning requires adding a tag to the project in the form of:
3534

36-
```
35+
```text
3736
schedule:<schedule>:<branch>:<engines>
3837
```
3938

@@ -90,8 +89,6 @@ Selection of the primary branch via the project configuration is shown in the im
9089

9190
![primary branch selection](images/primary-branch.png "Primary Branch Selection")
9291

93-
94-
9592
#### Element: `<engines>` (optional)
9693

9794
The value for `<engines>` can be one of the following:
@@ -141,8 +138,6 @@ project does not have a primary branch configured, the scan is not scheduled.
141138

142139
Group schedules always execute with all available engine types.
143140

144-
145-
146141
### Schedule Execution Logic
147142

148143
The execution environment is intended to be ephemeral. A shutdown
@@ -194,7 +189,6 @@ mapping option added to the container execution command line:
194189

195190
`-v $(pwd)/custom-ca.pem:/usr/local/share/ca-certificates/custom-ca.crt`
196191

197-
198192
### Required Secrets
199193

200194
Docker secrets are used to securely store secrets needed during runtime.
@@ -245,25 +239,25 @@ The following runtime environment variables are required to configure the system
245239

246240
|Variable|Default|Description|
247241
|-|-|-|
248-
|`CXONE_REGION`|N/A| Required for use with multi-tenant Checkmarx One tenants. The endpoint region used by your Checkmarx One tenant. This can be one of the following values: `US`, `US2`, `EU`, `EU2`, `DEU`, `ANZ`, `India`, `Singapore`, or `UAE`. If this is not supplied, the `SINGLE_TENANT_` variables must be defined.|
242+
|`CXONE_REGION`|N/A|Required for use with multi-tenant Checkmarx One tenants. The endpoint region used by your Checkmarx One tenant. This can be one of the following values: `US`, `US2`, `EU`, `EU2`, `DEU`, `ANZ`, `India`, `Singapore`, or `UAE`. If this is not supplied, the `SINGLE_TENANT_` variables must be defined.|
249243
|`SINGLE_TENANT_AUTH`|N/A|The name of the single-tenant IAM endpoint host. (e.g. `myhost.cxone.cloud`)|
250244
|`SINGLE_TENANT_API`|N/A|The name of the single-tenant API endpoint host. (e.g. `myhost.cxone.cloud`)|
251245
|`DEFAULT_SCHEDULE`|N/A|This defines the default schedule policy to apply to projects that do not have `schedule` tags. If not provided, projects that do not meet scheduling criteria via tags or group schedules will not be scanned with the scheduler. The value of this environment variable must be a valid `<schedule>` policy name. The branch and engine configurations are not defined as part of the default schedule.|
252-
|`GROUP_x`|N/A|`GROUP_` is considered a prefix with the remainder of the environment variable name being a key value. The key value is used to match `SCHEDULE_x` variables having the same key value. The value for this environment variable is a group path in the form of `/value/value/...` matching a group defined in Checkmarx One. This environment variable can be defined to apply a schedule to projects assigned to the defined group without the need to assign a `schedule` tag to the project.
246+
|`GROUP_x`|N/A|`GROUP_` is considered a prefix with the remainder of the environment variable name being a key value. The key value is used to match `SCHEDULE_x` variables having the same key value. The value for this environment variable is a group path in the form of `/value/value/...` matching a group defined in Checkmarx One. This environment variable can be defined to apply a schedule to projects assigned to the defined group without the need to assign a `schedule` tag to the project.|
253247
|`SCHEDULE_x`|N/A|`SCHEDULE_` is considered a prefix with the remainder of the environment variable name being a key value. The key value is used to match `GROUP_x` environment variables having the same key value. The value of this environment variable must be a valid `<schedule>` policy name.|
254248
|`LOG_LEVEL`|INFO|The logging level to control how much logging is emitted. Set to `DEBUG` for more verbose logging output.|
255-
|`SSL_VERIFY`|`True`| Set to `False` to turn off SSL certificate validation.|
256-
|`PROXY`| N/A | Set to the URL for an unauthenticated proxy. All http/s traffic will route through the specified proxy.|
257-
|`UPDATE_DELAY_SECONDS`| 43200 | The number of seconds to delay between checking for updates in the schedule.|
258-
|`POLICY_<name>`|N/A| Define a custom policy with `<name>`. See [Policy Definitions](#policy-definitions) for a description. This must be a valid [crontab](https://crontab.guru/) string.|
259-
|`TIMEZONE`| Etc/UTC | The [zoneinfo](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) string for the timezone. If the zoneinfo string is invalid or not set, the timezone will default to UTC.|
260-
|`THREADS`| 2 | Set to an integer value > 0 to increase the number of threads used when starting scans. This also sets the max concurrent SCM clones executed if using `FETCH_THROTTLE`.
261-
|`FETCH_THROTTLE`| False | Set to `True` to wait for the source code clone to complete before submitting another scan.
262-
|`FETCH_WAIT_SECONDS`| 300 | The maximum number of seconds to wait for the source code clone to complete before abandoning the wait. This allows other scan submission activity to continue in cases where the repository clone takes an excessively long time.
263-
|`RECENT_SCAN_HOURS`| 0 | This is used to set a policy of not performing a scheduled scan if a successful scan has been executed with the past hours indicated by this value. It is recommended that this value be less than your schedule cadence (e.g. if you scan every 24 hours, this should be a maximum of 23 hours). The check does not inspect the scan configuration, only that the scan has successfully completed. The value of 0 (default) disables this check.
264-
|`API_TIMEOUT` | 60 | Set to the number of seconds to wait for the Checkmarx One API to respond to requests before failure.
265-
|`API_RETRIES`| 3 | The number of times communicating with the Checkmarx One API will retry upon failure.
266-
|`API_RETRY_DELAY`| 15 | The maximum number of seconds to wait before retrying a failure Checkmarx One API request.
249+
|`SSL_VERIFY`|`True`|Set to `False` to turn off SSL certificate validation.|
250+
|`PROXY`|N/A|Set to the URL for an unauthenticated proxy. All http/s traffic will route through the specified proxy.|
251+
|`UPDATE_DELAY_SECONDS`|43200| The number of seconds to delay between checking for updates in the schedule.|
252+
|`POLICY_<name>`|N/A|Define a custom policy with `<name>`. See [Policy Definitions](#policy-definitions) for a description. This must be a valid [crontab](https://crontab.guru/) string.|
253+
|`TIMEZONE`|Etc/UTC|The [zoneinfo](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) string for the timezone. If the zoneinfo string is invalid or not set, the timezone will default to UTC.|
254+
|`THREADS`|2|Set to an integer value > 0 to increase the number of threads used when starting scans. This also sets the max concurrent SCM clones executed if using `FETCH_THROTTLE`.|
255+
|`FETCH_THROTTLE`|False|Set to `True` to wait for the source code clone to complete before submitting another scan.|
256+
|`FETCH_WAIT_SECONDS`|300| The maximum number of seconds to wait for the source code clone to complete before abandoning the wait. This allows other scan submission activity to continue in cases where the repository clone takes an excessively long time.|
257+
|`RECENT_SCAN_HOURS`|0|This is used to set a policy of not performing a scheduled scan if a successful scan has been executed with the past hours indicated by this value. It is recommended that this value be less than your schedule cadence (e.g. if you scan every 24 hours, this should be a maximum of 23 hours). The check does not inspect the scan configuration, only that the scan has successfully completed. The value of 0 (default) disables this check.|
258+
|`API_TIMEOUT`|60|Set to the number of seconds to wait for the Checkmarx One API to respond to requests before failure.|
259+
|`API_RETRIES`|3|The number of times communicating with the Checkmarx One API will retry upon failure.|
260+
|`API_RETRY_DELAY`|15|The maximum number of seconds to wait before retrying a failure Checkmarx One API request.|
267261

268262
### Policy Definitions
269263

@@ -280,25 +274,26 @@ The value assigned to the environment variable is a valid
280274
#### Examples of Policy Definitions
281275

282276
Policy definition named `mypolicy` that scans at midnight on weekdays. It can be referenced with the tag `schedule:mypolicy`.
283-
```
277+
278+
```text
284279
POLICY_MYPOLICY=0 0 * * 1-5
285280
```
286281

287282
Policy definition named `general-audit-policy` that scans every 30 minutes on weekdays. It can be referenced with
288283
the tag `schedule:general-audit-policy` or `schedule:general_audit_policy`.
289-
```
284+
285+
```text
290286
POLICY_GENERAL_AUDIT_POLICY=0,30 * * * 1-5
291287
```
292288

293-
## Execution
294-
289+
## Execution with Docker
295290

296291
### Obtaining the Container Image
297292

298293
The container image tag is `ghcr.io/checkmarx-ts/cxone/scan-scheduler:latest`. You can reference this image tag
299294
when running the image. If running Docker locally, for example, you can retrieve the image with this command:
300295

301-
```
296+
```bash
302297
docker pull ghcr.io/checkmarx-ts/cxone/scan-scheduler:latest
303298
```
304299

@@ -312,8 +307,7 @@ Execution methods may vary, but you must consider the following for execution:
312307
If running locally with Docker, for example, this command would run the scheduler setting the configuration environment variables
313308
and map `$(pwd)/run/secrets` to `/run/secrets`:
314309

315-
316-
```
310+
```bash
317311
docker run -it -v $(pwd)/run/secrets/:/run/secrets --env-file .env ghcr.io/checkmarx-ts/cxone/scan-scheduler:latest
318312
```
319313

@@ -329,13 +323,13 @@ There are two other runtimes that can be specified: `audit` and
329323
The `scanner` is the tool used by `Cron` to execute scans. It has some self-explanatory command line arguments that can be retrieved with the `-h` option.
330324
Executing `scanner` to see the help, for example, could be done using the following command line if running Docker locally:
331325

332-
```
326+
```bash
333327
docker run -it -v $(pwd)/run/secrets/:/run/secrets --env-file .env ghcr.io/checkmarx-ts/cxone/scan-scheduler:latest scanner -h
334328
```
335329

336330
Which would yield an output similar to the following:
337331

338-
```
332+
```shell
339333
A program to execute scans in CheckmarxOne as a Scheduler cron job.
340334

341335
options:
@@ -359,28 +353,71 @@ would create the schedule for all projects.
359353
If running Docker locally, the following command line could be used
360354
to dump a CSV to a local file:
361355

362-
```
356+
```bash
363357
docker run -it -v $(pwd)/run/secrets/:/run/secrets --env-file .env ghcr.io/checkmarx-ts/cxone/scan-scheduler:latest audit > out.csv
364358
```
365359

366-
367360
#### Python Debugger Execution
368361

369362
If you are a developer that wants to modify the code, you can execute
370363
the container so that you can attach a remote debugger instance. The
371364
following command line is an example of how to execute the scheduler
372365
so that it waits for a remote debugger to attach before starting:
373366

374-
```
367+
```bash
375368
docker run --rm -it -p 5678:5678 -v $(pwd)/run/secrets/:/run/secrets --env-file .env scheduler:latest -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 --wait-for-client scheduler.py
376369
```
377370

378371
The same can be done for the `scanner`:
379372

380-
```
373+
```bash
381374
docker run --rm -it -p 5678:5678 -v $(pwd)/run/secrets/:/run/secrets --env-file .env scheduler:latest -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 --wait-for-client scanner.py
382375
```
383376

377+
## Execution with Kubernetes
378+
379+
Execution with Kubernetes uses a Helm chart that is available as a `.tgz` file with the release artifacts. The Helm chart will deploy the scheduler
380+
to the cluster in the `checkmarx` namespace. The Helm chart includes a file named `values.yaml` that has documentation content for supplying
381+
configuration values that will be used to configure the container's runtime environment. Many of the configurations found in `values.yaml` can
382+
be overridden via the Helm command line or your own local copy of the file. While it is possible to modify the `values.yaml` file directly before
383+
installing the Helm chart, doing so will make it more difficult to update the deployment with new releases.
384+
385+
After the Helm chart is installed, you must define the generic secret containing the required secret values in the `checkmarx` namespace.
386+
One method is to deploy the generic secret via the `kubectl` command line. Example:
387+
388+
```bash
389+
kubectl create secret generic --namespace=checkmarx cxone-scan-scheduler-secrets \
390+
--from-literal=cxone_tenant=<tenant name> \
391+
--from-literal=cxone_oauth_client_id=<oauth client id> \
392+
--from-literal=cxone_oauth_client_secret=<oauth client secret>
393+
```
394+
395+
To map custom CA certificates to the container, provide the name of a ConfigMap
396+
for the `cxone.deployment.ca_certs_configmap_name` configuration parameter that holds the names of files containing custom CA
397+
certificates. In the following example, the ConfigMap named "cxone-scheduler-custom-cas" is created
398+
with the contents of the file `custom_ca.crt`:
399+
400+
```bash
401+
kubectl create configmap --namespace=checkmarx cxone-scheduler-custom-cas --from-file=custom_ca.crt
402+
```
403+
404+
If the value of `cxone.deployment.ca_certs_configmap_name` is not provided, no custom CA certificates
405+
will be mapped to the container.
406+
407+
A minimal install of the latest release with Helm is shown in the example below. After installing
408+
the Helm chart, the generic secret and ConfigMap need to be manually created in the `checkmarx` namespace for
409+
the scheduler to start.
410+
411+
```bash
412+
helm install scheduler https://github.com/checkmarx-ts/cxone-scan-scheduler/releases/latest/cxone-scan-scheduler_helm.tgz \
413+
--set cxone.deployment.secrets_name=cxone-scan-scheduler-secrets \
414+
--set cxone.deployment.ca_certs_configmap_name=cxone-scheduler-custom-cas \
415+
--set cxone.connection.multitenant.region=US \
416+
--set cxone.policies.debug="* * * * *" \
417+
--set cxone.operation.log_level=DEBUG \
418+
--set cxone.operation.schedule_update_seconds=30
419+
```
420+
384421
## Other Notes
385422

386423
### Scan Timing
@@ -473,5 +510,3 @@ This method is primarily useful to automate the scheduling of scans for projects
473510
an onboarding process. While it is possible to schedule scans with individual project tags,
474511
there may be cases where using group membership is a simpler method of assigning
475512
scan schedules.
476-
477-

0 commit comments

Comments
 (0)