Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use api.snyk.io as default url #99

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ snyk.api.organization=

# The base URL for all Snyk API endpoints.
# Documentation: https://snyk.docs.apiary.io/#introduction/api-url
# Default: https://snyk.io/api/v1/
#snyk.api.url=https://snyk.io/api/v1/
# Default: https://api.snyk.io/v1/
#snyk.api.url=https://api.snyk.io/v1/

# Path to an SSL Certificate for Snyk API in PEM format.
#snyk.api.sslCertificatePath=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public enum PluginConfiguration implements Configuration {
// general settings
API_URL("snyk.api.url", "https://snyk.io/api/v1/"),
API_URL("snyk.api.url", "https://api.snyk.io/v1/"),
API_TOKEN("snyk.api.token", ""),
API_ORGANIZATION("snyk.api.organization", ""),
API_SSL_CERTIFICATE_PATH("snyk.api.sslCertificatePath", ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PluginConfigurationTest {
@Test
void checkDefaultValues() {
assertAll("should be not empty",
() -> assertEquals("https://snyk.io/api/v1/", API_URL.defaultValue(), getAssertionMessage(API_URL, "default value must be 'https://snyk.io/api/v1/'")),
() -> assertEquals("https://api.snyk.io/v1/", API_URL.defaultValue(), getAssertionMessage(API_URL, "default value must be 'https://api.snyk.io/v1/'")),
() -> assertEquals("false", SCANNER_BLOCK_ON_API_FAILURE.defaultValue(), getAssertionMessage(SCANNER_BLOCK_ON_API_FAILURE, "default value must be 'false'")),
() -> assertEquals("low", SCANNER_VULNERABILITY_THRESHOLD.defaultValue(), getAssertionMessage(SCANNER_VULNERABILITY_THRESHOLD, "default value must be 'low'")),
() -> assertEquals("low", SCANNER_LICENSE_THRESHOLD.defaultValue(), getAssertionMessage(SCANNER_LICENSE_THRESHOLD, "default value must be 'low'"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void shouldTestPipPackage() throws Exception {
TestResult result = scanner.scan(fileLayoutInfo, repoPath);
assertFalse(result.success);
assertEquals(1, result.dependencyCount);
assertEquals(5, result.issues.vulnerabilities.size());
assertEquals(6, result.issues.vulnerabilities.size());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to bump this to 6 as this seems to use real data and number of vulns has increased.

assertEquals("pip", result.packageManager);
assertEquals(org, result.organisation.id);
assertEquals("https://snyk.io/vuln/pip%3Aurllib3%401.25.7", result.packageDetailsURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void testScanPythonItem_withVulns() throws Exception {
TestResult tr = testResultCaptor.getValue();
assertFalse(tr.success);
assertEquals(1, tr.dependencyCount);
assertEquals(5, tr.issues.vulnerabilities.size());
assertEquals(6, tr.issues.vulnerabilities.size());
assertEquals("pip", tr.packageManager);
assertEquals(testSetup.org, tr.organisation.id);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
snyk.api.url=https://snyk.io/api/v1/
snyk.api.url=https://api.snyk.io/v1/
snyk.api.token=my-api-token
snyk.api.organization=my-api-organization
#
Expand Down
2 changes: 1 addition & 1 deletion helm-install/install-helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pushd "$SCRIPT_DIR/.." || exit 1
if [[ $SNYK_TOKEN == "" ]]; then
$SNYK auth
fi
ORG=$(curl -s -H "Authorization: token $SNYK_TOKEN" https://snyk.io/api/v1/orgs | jq -r '.orgs|first|.id')
ORG=$(curl -s -H "Authorization: token $SNYK_TOKEN" https://api.snyk.io/v1/orgs | jq -r '.orgs|first|.id')

# monkey patching config file
pushd plugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void createSnykClient_shouldThrowIAE_ifTokenIsNull() {
void createSnykConfig_shouldReturnDefaultValues_ifNotDefined() {
Config config = new Config("snyk-api-token");

assertEquals("https://snyk.io/api/v1/", config.baseUrl);
assertEquals("https://api.snyk.io/v1/", config.baseUrl);
assertEquals("snyk-sdk-java", config.userAgent);
}

Expand Down
2 changes: 1 addition & 1 deletion snyk-sdk/src/main/java/io/snyk/sdk/SnykConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static SnykConfig withDefaults() {

public static class Builder {
private String token;
private String baseUrl = "https://snyk.io/api/v1/";
private String baseUrl = "https://api.snyk.io/v1/";
private String userAgent = "snyk-sdk-java";
private boolean trustAllCertificates = false;
private String sslCertificatePath = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void shouldIncludeBaseUrlWithPath() {
assertEquals(SnykHttpRequestBuilder.create(configWithDefaultBaseUrl)
.build()
.uri().toString(),
"https://snyk.io/api/v1/");
"https://api.snyk.io/v1/");

String otherBaseUrl = "https://other-host/some-prefix/";
SnykConfig configWithDifferentBaseUrl = SnykConfig.newBuilder().setBaseUrl(otherBaseUrl).build();
Expand All @@ -34,7 +34,7 @@ void shouldIncludeBaseUrlWithPath() {
void shouldOnlyIncludeNonNullQueryParameters() {
SnykConfig config = SnykConfig.withDefaults();

assertEquals("https://snyk.io/api/v1/some/endpoint?org=abc123",
assertEquals("https://api.snyk.io/v1/some/endpoint?org=abc123",
SnykHttpRequestBuilder.create(config)
.withPath("some/endpoint")
.withQueryParam("org", "abc123")
Expand All @@ -48,7 +48,7 @@ void shouldOnlyIncludeNonNullQueryParameters() {
@Test
void shouldOnlyIncludePresentQueryParameters() {
SnykConfig config = SnykConfig.withDefaults();
assertEquals("https://snyk.io/api/v1/some/endpoint?org=abc123",
assertEquals("https://api.snyk.io/v1/some/endpoint?org=abc123",
SnykHttpRequestBuilder.create(config)
.withPath("some/endpoint")
.withQueryParam("org", Optional.of("abc123"))
Expand All @@ -62,7 +62,7 @@ void shouldOnlyIncludePresentQueryParameters() {
@Test
void shouldIncludeMultipleQueryParameters() {
SnykConfig config = SnykConfig.withDefaults();
assertEquals("https://snyk.io/api/v1/some/endpoint?org=abc123&foo=bar",
assertEquals("https://api.snyk.io/v1/some/endpoint?org=abc123&foo=bar",
SnykHttpRequestBuilder.create(config)
.withPath("some/endpoint")
.withQueryParam("org", "abc123")
Expand Down
Loading