-
Notifications
You must be signed in to change notification settings - Fork 12
get services from API, removing sidecar requirement #772
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -395,7 +395,11 @@ func main() { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Create scan failure reporter (sends SBOM failures to careportreceiver for user notifications) | ||||||||||||||||||||||
| var failureReporter sbommanager.SbomFailureReporter | ||||||||||||||||||||||
| if services, svcErr := config.LoadServiceURLs("/etc/config/services.json"); svcErr == nil && services.GetReportReceiverHttpUrl() != "" { | ||||||||||||||||||||||
| apiURL := os.Getenv("API_URL") | ||||||||||||||||||||||
| if apiURL == "" { | ||||||||||||||||||||||
| apiURL = "api.armosec.io" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| if services, svcErr := config.LoadServiceURLs(apiURL); svcErr == nil && services.GetReportReceiverHttpUrl() != "" { | ||||||||||||||||||||||
| failureReporter = sbommanagerv1.NewHTTPSbomFailureReporter(services.GetReportReceiverHttpUrl(), accessKey, clusterData.AccountID, clusterData.ClusterName) | ||||||||||||||||||||||
| logger.L().Info("scan failure reporting enabled", helpers.String("eventReceiverURL", services.GetReportReceiverHttpUrl())) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+402
to
405
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don’t swallow service-discovery errors silently. At Line 402, Proposed patch if services, svcErr := config.LoadServiceURLs(apiURL); svcErr == nil && services.GetReportReceiverHttpUrl() != "" {
failureReporter = sbommanagerv1.NewHTTPSbomFailureReporter(services.GetReportReceiverHttpUrl(), accessKey, clusterData.AccountID, clusterData.ClusterName)
logger.L().Info("scan failure reporting enabled", helpers.String("eventReceiverURL", services.GetReportReceiverHttpUrl()))
+ } else if svcErr != nil {
+ logger.L().Warning("scan failure reporting disabled: unable to load backend services", helpers.Error(svcErr), helpers.String("apiURL", apiURL))
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In github.com/kubescape/backend/pkg/servicediscovery/v3, does NewServiceDiscoveryClientV3 require an absolute URL including scheme (e.g., https://...), or does it accept bare hostnames like api.armosec.io?💡 Result:
NewServiceDiscoveryClientV3 in github.com/kubescape/backend/pkg/servicediscovery/v3 likely requires an absolute URL including scheme. Evidence from Kubescape operator usage shows service discovery fetching from https://api.armosec.io/api/v1/servicediscovery, indicating HTTPS absolute URLs are used. Bare hostnames like api.armosec.io are used in contexts like firewall rules but curl commands prepend https://, suggesting the client expects full URLs. No source code found explicitly stating bare hostnames are accepted, and standard Go HTTP clients typically require schemes for absolute URLs.
Citations:
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 776
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 348
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 695
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 446
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 46
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 46
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 6609
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 823
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 83
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 89
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 2052
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 1890
Add URL scheme to default API_URL and normalize user-provided values.
Line 400 defaults to
api.armosec.iowithout a scheme. When passed toNewServiceDiscoveryClientV3(), this bare hostname will fail service discovery (which requires an absolute URL), preventing scan-failure reporting from being enabled.Additionally, users who provide a custom
API_URLenvironment variable without a scheme will encounter the same failure.Proposed patch
apiURL := os.Getenv("API_URL") if apiURL == "" { - apiURL = "api.armosec.io" + apiURL = "https://api.armosec.io" + } else if !strings.Contains(apiURL, "://") { + apiURL = "https://" + apiURL }🤖 Prompt for AI Agents