Skip to content

Commit 639a4a6

Browse files
committed
Generate config documentation from application.properties
Leverages the `GenerateConfigDocs` JBang script (https://github.com/DependencyTrack/jbang-catalog/blob/main/GenerateConfigDocs.java) to generate reference documentation from the `application.properties` file. This makes `application.properties` the single source of truth for configuration options. We no longer need to copy-paste its contents to multiple places for documentation purposes. The documentation is re-generated automatically whenever `application.properties` changes. This is already done for the Hyades project (https://github.com/DependencyTrack/hyades/blob/2f95363fbf51423876a8eb2c7f0bc55a53ba85f9/DEVELOPING.md?plain=1#L11-L61) and turned out to be useful, so backporting it here. Signed-off-by: nscuro <nscuro@protonmail.com>
1 parent 18d00cf commit 639a4a6

19 files changed

Lines changed: 3342 additions & 773 deletions
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This file is part of Dependency-Track.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
# Copyright (c) OWASP Foundation. All Rights Reserved.
17+
name: Update Config Documentation
18+
19+
on:
20+
push:
21+
branches:
22+
- master
23+
paths:
24+
- ".github/workflows/update-config-docs.yml"
25+
- "dev/scripts/config-docs.md.peb"
26+
- "src/main/resources/application.properties"
27+
workflow_dispatch: { }
28+
29+
permissions: { }
30+
31+
jobs:
32+
generate-docs:
33+
name: Generate Documentation
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 5
36+
permissions:
37+
contents: write
38+
pull-requests: write
39+
if: "${{ github.repository_owner == 'DependencyTrack' }}"
40+
steps:
41+
- name: Checkout Repository
42+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # tag=v4.1.6
43+
- name: Generate Documentation
44+
uses: jbangdev/jbang-action@74844c9631cf1f35650427323e9bb3ffa41dfbd9 # tag=v0.115.0
45+
with:
46+
trust: https://github.com/DependencyTrack/jbang-catalog
47+
script: gen-config-docs@DependencyTrack
48+
scriptargs: >-
49+
--template ./dev/scripts/config-docs.md.peb
50+
--output docs/_docs/getting-started/configuration-apiserver.md
51+
./src/main/resources/application.properties
52+
- name: Create Pull Request
53+
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # tag=v6.0.5
54+
with:
55+
add-paths: "docs/_docs/getting-started/configuration-apiserver.md"
56+
branch: update-config-docs
57+
body: "Updates configuration documentation."
58+
commit-message: Update config docs
59+
delete-branch: true
60+
labels: documentation
61+
signoff: true
62+
title: Update config docs

dev/scripts/config-docs.md.peb

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
---
2+
title: Configuration - API Server
3+
category: Getting Started
4+
chapter: 1
5+
order: 7
6+
---
7+
<!--
8+
GENERATED. DO NOT EDIT.
9+
10+
Generated with: {{ generateCommand }}
11+
-->
12+
13+
The central configuration file `application.properties` resides in the classpath of the WAR by default.
14+
This configuration file controls many performance tuning parameters but is most useful for defining
15+
optional external database sources, directory services (LDAP), and proxy settings.
16+
17+
For containerized deployments, the properties defined in the configuration file can also be specified
18+
as environment variables. All environment variables are upper case with periods (.) replaced with underscores (_).
19+
Refer to the [Docker instructions]({{ "{{ site.baseurl }}{% link _docs/getting-started/deploy-docker.md %}" }}) for
20+
configuration examples using environment variables.
21+
22+
Dependency-Track administrators are highly encouraged to create a copy of this file in the
23+
Dependency-Track data directory and customize it prior to deploying to production.
24+
25+
26+
> The default embedded H2 database is designed to quickly evaluate and experiment with Dependency-Track.
27+
> Do not use the embedded H2 database in production environments.
28+
>
29+
> See: [Database Support]({{ "{{ site.baseurl }}{% link _docs/getting-started/database-support.md %}" }}).
30+
31+
32+
To start Dependency-Track using custom configuration, add the system property
33+
`alpine.application.properties` when executing. For example:
34+
35+
```bash
36+
-Dalpine.application.properties=~/.dependency-track/application.properties
37+
```
38+
39+
### Proxy Configuration
40+
41+
Proxy support can be configured in one of two ways, using the proxy settings defined
42+
in `application.properties` or through environment variables. By default, the system
43+
will attempt to read the `https_proxy`, `http_proxy` and `no_proxy` environment variables. If one
44+
of these are set, Dependency-Track will use them automatically.
45+
46+
`no_proxy` specifies URLs that should be excluded from proxying.
47+
This can be a comma-separated list of hostnames, domain names, or a mixture of both.
48+
If a port number is specified for a URL, only the requests with that port number to that URL will be excluded from proxying.
49+
`no_proxy` can also set to be a single asterisk ('*') to match all hosts.
50+
51+
Dependency-Track supports proxies that require BASIC, DIGEST, and NTLM authentication.
52+
53+
### Logging Levels
54+
55+
Logging levels (INFO, WARN, ERROR, DEBUG, TRACE) can be specified by passing the level
56+
to the `dependencyTrack.logging.level` system property on startup. For example, the
57+
following command will start Dependency-Track (embedded) with DEBUG logging:
58+
59+
```bash
60+
java -Xmx4G -DdependencyTrack.logging.level=DEBUG -jar dependency-track-embedded.war
61+
```
62+
63+
For Docker deployments, simply set the `LOGGING_LEVEL` environment variable to one of
64+
INFO, WARN, ERROR, DEBUG, or TRACE.
65+
66+
### Secret Key
67+
68+
Dependency-Track will encrypt certain confidential data (e.g. access tokens for external service providers) with AES256
69+
prior to storing it in the database. The secret key used for encrypting and decrypting will be automatically generated
70+
when Dependency-Track starts for the first time, and is placed in `<alpine.data.directory>/keys/secret.key`
71+
(`/data/.dependency-track/keys/secret.key` for containerized deployments).
72+
73+
Starting with Dependency-Track 4.7, it is possible to change the location of the secret key via the `alpine.secret.key.path`
74+
property. This makes it possible to use Kubernetes secrets for example, to mount secrets into the custom location.
75+
76+
Secret keys may be generated manually upfront instead of relying on Dependency-Track to do it. This can be achieved
77+
with OpenSSL like this:
78+
79+
```shell
80+
openssl rand 32 > secret.key
81+
```
82+
83+
> Note that the default key format has changed in version 4.7. While existing keys using the old format will continue
84+
> to work, keys for new instances will be generated in the new format. Old keys may be converted using the following
85+
> [JShell](https://docs.oracle.com/en/java/javase/17/jshell/introduction-jshell.html) script:
86+
> ```java
87+
> import java.io.ObjectInputStream;
88+
> import java.nio.file.Files;
89+
> import java.nio.file.Paths;
90+
> import javax.crypto.SecretKey;
91+
> String inputFilePath = System.getProperty("secret.key.input")
92+
> String outputFilePath = System.getProperty("secret.key.output");
93+
> SecretKey secretKey = null;
94+
> System.out.println("Reading old key from " + inputFilePath);
95+
> try (var fis = Files.newInputStream(Paths.get(inputFilePath));
96+
> var ois = new ObjectInputStream(fis)) {
97+
> secretKey = (SecretKey) ois.readObject();
98+
> }
99+
> System.out.println("Writing new key to " + outputFilePath);
100+
> try (var fos = Files.newOutputStream(Paths.get(outputFilePath))) {
101+
> fos.write(secretKey.getEncoded());
102+
> }
103+
> /exit
104+
> ```
105+
> Example execution:
106+
> ```shell
107+
> jshell -R"-Dsecret.key.input=$HOME/.dependency-track/keys/secret.key" -R"-Dsecret.key.output=secret.key.new" convert-key.jsh
108+
> ```
109+
110+
---
111+
112+
## Reference
113+
114+
<ul>
115+
{% for entry in propertiesByCategory %}
116+
<li><a href="#{{ entry.key | lower | replace({' ': '-'}) }}">{{ entry.key }}</a></li>
117+
{% endfor %}
118+
</ul>
119+
120+
{% for entry in propertiesByCategory %}
121+
### {{ entry.key }}
122+
123+
{% for property in entry.value -%}
124+
#### {{ property.name }}
125+
126+
{{ property.description | replace({' ': '
127+
'}) }}
128+
129+
<table>
130+
<tbody style="border: 0">
131+
<tr>
132+
<th style="text-align: right">Required</th>
133+
<td style="border-width: 0">{{ property.required ? "Yes" : "No" }}</td>
134+
</tr>
135+
<tr>
136+
<th style="text-align: right">Type</th>
137+
<td style="border-width: 0">{{ property.type }}</td>
138+
</tr>
139+
{% if property.validValues -%}
140+
<tr>
141+
<th style="text-align: right">Valid Values</th>
142+
<td style="border-width: 0">{{ property.validValues }}</td>
143+
</tr>
144+
{% endif -%}
145+
<tr>
146+
<th style="text-align: right">Default</th>
147+
<td style="border-width: 0">{{ property.defaultValue }}</td>
148+
</tr>
149+
{% if property.example -%}
150+
<tr>
151+
<th style="text-align: right">Example</th>
152+
<td style="border-width: 0">{{ property.example }}</td>
153+
</tr>
154+
{% endif -%}
155+
<tr>
156+
<th style="text-align: right">ENV</th>
157+
<td style="border-width: 0">{{ property.env }}</td>
158+
</tr>
159+
</tbody>
160+
</table>
161+
162+
{% endfor %}
163+
{% endfor %}

docs/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ group :jekyll_plugins do
1111
gem 'jekyll-sitemap', '1.4.0'
1212
gem 'jekyll-redirect-from', '0.16.0'
1313
gem 'jekyll-mermaid', '1.0.0'
14+
# https://github.com/ffi/ffi/issues/1103#issuecomment-2186974923
15+
gem 'ffi', '< 1.17.0'
1416
end

docs/_docs/datasources/snyk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ When evaluating the severity of a vulnerability, it's important to note that the
9393
**NOTE:** For Beta version, user can select either from NVD or SNYK to prioritize the cvss vectors.
9494

9595
[Authentication for API]: https://docs.snyk.io/snyk-api-info/authentication-for-api
96-
[Configuration]: {{ site.baseurl }}{% link _docs/getting-started/configuration.md %}
96+
[Configuration]: {{ site.baseurl }}{% link _docs/getting-started/configuration-apiserver.md %}
9797
[Finding the Snyk ID and internal name of an Organization]: https://docs.snyk.io/products/snyk-code/cli-for-snyk-code/before-you-start-set-the-organization-for-the-cli-tests/finding-the-snyk-id-and-internal-name-of-an-organization
9898
[Monitoring]: {{ site.baseurl }}{% link _docs/getting-started/monitoring.md %}#retries
9999
[REST API documentation]: https://apidocs.snyk.io

0 commit comments

Comments
 (0)