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

[openapi2kong] Fix server port parsing #105

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

danielpoonwj
Copy link
Contributor

#104

This change increases bit size in strconv.ParseInt from 16 to 64 to allow higher port numbers. Also previously when the input was unparseable, the error was ignored. Now we can return an error instead of silently setting a potentially incorrect port number.

@codecov-commenter
Copy link

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (dab2c18) 70.28% compared to head (b29cf5a) 70.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #105      +/-   ##
==========================================
- Coverage   70.28%   70.20%   -0.08%     
==========================================
  Files          17       17              
  Lines        2453     2457       +4     
==========================================
+ Hits         1724     1725       +1     
- Misses        611      614       +3     
  Partials      118      118              
Files Coverage Δ
openapi2kong/service.go 82.75% <40.00%> (-1.36%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Tieske Tieske left a comment

Choose a reason for hiding this comment

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

Thx! Maybe one of the existing test files can be modified to carry a higher port number as a testcase?

@@ -230,7 +230,11 @@ func CreateKongService(
if service["port"] == nil {
if targets[0].Port() != "" {
// port is provided, so parse it
service["port"], _ = strconv.ParseInt(targets[0].Port(), 10, 16)
parsedPort, err := strconv.ParseInt(targets[0].Port(), 10, 64)
Copy link
Member

Choose a reason for hiding this comment

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

I think using ParseUint with bitsize 16 should do it right? That would also ensure any negative numbers are caught by the error handler.

@Tieske Tieske merged commit b73332c into Kong:main Nov 13, 2023
3 checks passed
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.

None yet

3 participants