Skip to content

Commit 57bd6ad

Browse files
committed
refactor(advisor)!: Move advisor configuration classes to advisor module
Since the previous commit the model does not require the advisor specific configuration classes anymore. Move them to the advisor module to prepare for moving the advice provider implementations to their own plugin modules. Signed-off-by: Martin Nonnenmacher <[email protected]>
1 parent 8a5fbbe commit 57bd6ad

File tree

15 files changed

+246
-145
lines changed

15 files changed

+246
-145
lines changed

advisor/src/funTest/kotlin/OsvFunTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import io.kotest.matchers.shouldBe
2626
import java.time.Instant
2727

2828
import org.ossreviewtoolkit.advisor.advisors.Osv
29+
import org.ossreviewtoolkit.advisor.advisors.OsvConfiguration
2930
import org.ossreviewtoolkit.model.AdvisorResult
3031
import org.ossreviewtoolkit.model.Identifier
3132
import org.ossreviewtoolkit.model.Package
32-
import org.ossreviewtoolkit.model.config.OsvConfiguration
3333
import org.ossreviewtoolkit.model.readValue
3434
import org.ossreviewtoolkit.model.utils.toPurl
3535
import org.ossreviewtoolkit.utils.test.getAssetFile

advisor/src/main/kotlin/advisors/GitHubDefects.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import org.ossreviewtoolkit.model.Defect
5050
import org.ossreviewtoolkit.model.Issue
5151
import org.ossreviewtoolkit.model.Package
5252
import org.ossreviewtoolkit.model.Severity
53-
import org.ossreviewtoolkit.model.config.GitHubDefectsConfiguration
5453
import org.ossreviewtoolkit.model.config.PluginConfiguration
5554
import org.ossreviewtoolkit.model.createAndLogIssue
5655
import org.ossreviewtoolkit.utils.common.Options
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (C) 2021 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
package org.ossreviewtoolkit.advisor.advisors
21+
22+
import com.fasterxml.jackson.annotation.JsonInclude
23+
import com.fasterxml.jackson.annotation.JsonProperty
24+
25+
/**
26+
* The configuration for the GitHub Defects advisor.
27+
*/
28+
data class GitHubDefectsConfiguration(
29+
/**
30+
* The access token to authenticate against the GitHub GraphQL endpoint.
31+
*/
32+
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
33+
val token: String? = null,
34+
35+
/**
36+
* The URL of the GraphQL endpoint to be accessed by the service. If undefined, default is the endpoint of the
37+
* official GitHub GraphQL API.
38+
*/
39+
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
40+
val endpointUrl: String? = null,
41+
42+
/**
43+
* A list with labels to be used for filtering GitHub issues. With GitHub's data model for issues, it is not
44+
* possible to determine whether a specific issue is actually a defect or something else, e.g. a feature request.
45+
* Via this property, it is possible to limit the issues retrieved by the GitHub defects advisor by filtering for
46+
* specific label values. The filtering works as follows:
47+
* - Each string in this list refers to a label to be matched. The strings are processed in order.
48+
* - If for an issue a label with the name of the current string is found, the issue is included into the result
49+
* set.
50+
* - If the current string starts with one of the characters '-' or '!', it defines an exclusion. So, if an issue
51+
* contains a label named like the current string with the first character removed, this issue is not added to
52+
* the result set, and filtering stops here. (The ordered processing resolves conflicting filters, as the first
53+
* match wins.)
54+
* - Label name matches are case-insensitive.
55+
* - Wildcards are supported; a "*" matches arbitrary characters.
56+
* - If the end of the list is reached and no match was found, the issue is not added to the result set. In order
57+
* to have all issues included for which no specific exclusion was found, a wildcard match "*" can be added at
58+
* the end.
59+
* Per default, some of GitHub's default labels are excluded that typically indicate that an issue is not a defect
60+
* (see https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/managing-labels#about-default-labels)
61+
*/
62+
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
63+
val labelFilter: List<String> = listOf("!duplicate", "!enhancement", "!invalid", "!question", "*"),
64+
65+
/**
66+
* The maximum number of defects that are retrieved from a single repository. If a repository contains more
67+
* issues, only this number is returned (the newest ones). Popular libraries hosted on GitHub can really have a
68+
* large number of issues; therefore, it makes sense to restrict the result set produced by this advisor.
69+
*/
70+
val maxNumberOfIssuesPerRepository: Int? = null,
71+
72+
/**
73+
* Determines the number of requests to the GitHub GraphQL API that are executed in parallel. Rather than querying
74+
* each repository one after the other, fetching the data of multiple repositories concurrently can reduce the
75+
* execution times for this advisor implementation. If unspecified, a default value for parallel executions as
76+
* defined in the _GitHubDefects_ class is used.
77+
*/
78+
val parallelRequests: Int? = null
79+
)

advisor/src/main/kotlin/advisors/NexusIq.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import org.ossreviewtoolkit.model.Issue
4141
import org.ossreviewtoolkit.model.Package
4242
import org.ossreviewtoolkit.model.Vulnerability
4343
import org.ossreviewtoolkit.model.VulnerabilityReference
44-
import org.ossreviewtoolkit.model.config.NexusIqConfiguration
4544
import org.ossreviewtoolkit.model.config.PluginConfiguration
4645
import org.ossreviewtoolkit.model.utils.PurlType
4746
import org.ossreviewtoolkit.model.utils.getPurlType
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (C) 2020 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
package org.ossreviewtoolkit.advisor.advisors
21+
22+
import com.fasterxml.jackson.annotation.JsonInclude
23+
import com.fasterxml.jackson.annotation.JsonProperty
24+
25+
/**
26+
* The configuration for Nexus IQ as a security vulnerability provider.
27+
*/
28+
data class NexusIqConfiguration(
29+
/**
30+
* The URL to use for REST API requests against the server.
31+
*/
32+
val serverUrl: String,
33+
34+
/**
35+
* A URL to use as a base for browsing vulnerability details. Defaults to the server URL.
36+
*/
37+
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
38+
val browseUrl: String = serverUrl,
39+
40+
/**
41+
* The username to use for authentication. If not both [username] and [password] are provided, authentication is
42+
* disabled.
43+
*/
44+
val username: String? = null,
45+
46+
/**
47+
* The password to use for authentication. If not both [username] and [password] are provided, authentication is
48+
* disabled.
49+
*/
50+
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
51+
val password: String? = null
52+
)

advisor/src/main/kotlin/advisors/OssIndex.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import org.ossreviewtoolkit.model.Issue
3737
import org.ossreviewtoolkit.model.Package
3838
import org.ossreviewtoolkit.model.Vulnerability
3939
import org.ossreviewtoolkit.model.VulnerabilityReference
40-
import org.ossreviewtoolkit.model.config.OssIndexConfiguration
4140
import org.ossreviewtoolkit.model.config.PluginConfiguration
4241
import org.ossreviewtoolkit.model.utils.toPurl
4342
import org.ossreviewtoolkit.utils.common.Options
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (C) 2023 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
package org.ossreviewtoolkit.advisor.advisors
21+
22+
import com.fasterxml.jackson.annotation.JsonProperty
23+
24+
/**
25+
* The configuration for the OSS Index provider.
26+
*/
27+
data class OssIndexConfiguration(
28+
/**
29+
* The base URL of the OSS Index REST API. If undefined, default base URL for the REST API of the public OSS Index
30+
* service.
31+
*/
32+
val serverUrl: String? = null,
33+
34+
/**
35+
* The username to use for authentication. If not both [username] and [password] are provided, authentication is
36+
* disabled.
37+
*/
38+
val username: String? = null,
39+
40+
/**
41+
* The password to use for authentication. If not both [username] and [password] are provided, authentication is
42+
* disabled.
43+
*/
44+
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
45+
val password: String? = null
46+
)

advisor/src/main/kotlin/advisors/Osv.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import org.ossreviewtoolkit.model.AdvisorSummary
4040
import org.ossreviewtoolkit.model.Identifier
4141
import org.ossreviewtoolkit.model.Package
4242
import org.ossreviewtoolkit.model.VulnerabilityReference
43-
import org.ossreviewtoolkit.model.config.OsvConfiguration
4443
import org.ossreviewtoolkit.model.config.PluginConfiguration
4544
import org.ossreviewtoolkit.utils.common.Options
4645
import org.ossreviewtoolkit.utils.common.collectMessages
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (C) 2022 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
package org.ossreviewtoolkit.advisor.advisors
21+
22+
/**
23+
* The configuration for the Google OSV vulnerability provider.
24+
*/
25+
data class OsvConfiguration(
26+
/**
27+
* The base URL of the OSV REST API. If undefined, default is the production endpoint of the official OSV.dev API.
28+
*/
29+
val serverUrl: String? = null
30+
)

advisor/src/main/kotlin/advisors/VulnerableCode.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import org.ossreviewtoolkit.model.Severity
3636
import org.ossreviewtoolkit.model.Vulnerability
3737
import org.ossreviewtoolkit.model.VulnerabilityReference
3838
import org.ossreviewtoolkit.model.config.PluginConfiguration
39-
import org.ossreviewtoolkit.model.config.VulnerableCodeConfiguration
4039
import org.ossreviewtoolkit.model.createAndLogIssue
4140
import org.ossreviewtoolkit.model.utils.toPurl
4241
import org.ossreviewtoolkit.utils.common.Options

0 commit comments

Comments
 (0)