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

fix #5041: adding raw methods #5064

Merged
merged 1 commit into from
Apr 28, 2023
Merged

fix #5041: adding raw methods #5064

merged 1 commit into from
Apr 28, 2023

Conversation

shawkins
Copy link
Contributor

@shawkins shawkins commented Apr 20, 2023

Description

Fix #5041 with very simple raw method.

Some alternatives / additional work:

  • additionally, or instead, provide non-blocking methods
  • add more methods around the proxy url construction

Any scenario beyond this - requiring the manipulation of headers for example - we can direct the user to use HttpClient.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

* @param uri must start with / if relative
* @return the response, or null if a 404 code
*/
default String raw(String uri) {
Copy link
Member

Choose a reason for hiding this comment

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

If it didn't entail a security issue I'd suggest to use URI as the parameter type instead.

} else if (payload != null) {
body = Serialization.asJson(payload);
}
HttpRequest request = httpClient.newHttpRequestBuilder().uri(uri).method(method, JSON, body).build();
Copy link
Member

Choose a reason for hiding this comment

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

in relation to my previous comment about security.

In which cases do we might want to perform a request to a non-relative URL?

Copy link
Member

Choose a reason for hiding this comment

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

@shawkins, I'm going to merge as it is, but I think it's important to clarify this point. If there's no clear case, we might want to limit this to access only cluster-scoped URIs in order to prevent sending sensitive data to other locations.

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

11.1% 11.1% Coverage
0.0% 0.0% Duplication

@manusa manusa merged commit f7273dc into fabric8io:master Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for raw requests
4 participants