Skip to content

Commit

Permalink
chore: change check for fedramp to rely on the snykgov.io domain only
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Aug 31, 2023
1 parent 59e4611 commit c4cda66
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/main/kotlin/snyk/common/CustomEndpoints.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,38 @@ internal fun resolveCustomEndpoint(endpointUrl: String?): String {
}

fun URI.isSnykTenant() =
isSnykDomain() && (host.startsWith("app.") || host == "snyk.io" || isDev()) && path.endsWith("/api")
isSnykDomain() &&
path.lowercase().endsWith("/api") &&
(host.lowercase().startsWith("app.") ||

Check warning

Code scanning / detekt

Reports missing newlines (e.g. between parentheses of a multi-line function call Warning

Missing newline after "("

Check warning

Code scanning / detekt

Reports missing newlines (e.g. between parentheses of a multi-line function call Warning

Missing newline before ")"
host.lowercase() == "snyk.io" ||
isDev())

fun URI.isSnykApi() = isSnykDomain() && (host.startsWith("api.") || path.endsWith("/api"))
fun URI.isSnykApi() = isSnykDomain() && (host.lowercase().startsWith("api.") || path.lowercase().endsWith("/api"))

fun URI.toSnykAPIv1(): URI {
val host = host
val host = host.lowercase()
.replaceFirst("app.", "api.")
.replaceFirst("deeproxy.", "api.")
.prefixIfNot("api.")

return URI(scheme, host, "/v1/", null)
}

fun URI.isSnykDomain() = host != null && (host.endsWith("snyk.io") || host.endsWith("snykgov.io"))
fun URI.isSnykDomain() = host != null &&
(

Check warning

Code scanning / detekt

Reports missing newlines (e.g. between parentheses of a multi-line function call Warning

Missing newline before ")"
host.lowercase().endsWith(".snyk.io") ||
host.lowercase() == "snyk.io" ||
host.lowercase().endsWith(".snykgov.io"))

fun URI.isDeeproxy() = isSnykDomain() && host.startsWith("deeproxy.")
fun URI.isDeeproxy() = isSnykDomain() && host.lowercase().startsWith("deeproxy.")

fun URI.isOauth() = host != null && host.endsWith(".snykgov.io")
fun URI.isSnykGov() = host != null && host.lowercase().endsWith(".snykgov.io")

fun URI.isDev() = isSnykDomain() && host.startsWith("dev.")
fun URI.isOauth() = isSnykGov()

fun URI.isFedramp() = isOauth() && host.contains("fedramp")
fun URI.isDev() = isSnykDomain() && host.lowercase().startsWith("dev.")

fun URI.isFedramp() = isSnykGov()

fun isFedramp(): Boolean {
val settings = pluginSettings()
Expand Down

0 comments on commit c4cda66

Please sign in to comment.