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

feat: add secure flag to gitlab config #1129

Merged
merged 5 commits into from
Jul 10, 2024

Conversation

vonBrax
Copy link
Contributor

@vonBrax vonBrax commented Jul 9, 2024

This PR adds a new flag to the gitlab config options: secure.

If the value of this flag is not undefined, it will be forward to https request library (got), which in turn also forwards it to node's https.request method as the rejectUnauthorized flag.

The rejectUnauthorized flag is true by default. When its value is false, it allows node to make https requests to servers without verifying the server certificate against the list of trusted CA's.

The goal of this PR is to reduce the effort to create gitlab releases for teams working with self-hosted private gitlab instances, skipping the need of having to pass CA certificates around.

Fix: #1125

Copy link
Collaborator

@webpro webpro left a comment

Choose a reason for hiding this comment

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

Looks good! One nitpick, but also a request: any chance you could add some test coverage? There's a few for the GitLab plugin already.

certificateAuthority: certificateAuthorityFile ? fs.readFileSync(certificateAuthorityFile) : undefined,
rejectUnauthorized: typeof secure === 'boolean' ? secure : undefined
};
const https = _.merge({}, httpsOptions);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we don't need this intermediate step?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's correct, we don't really need it. My idea here was to use lodash merge because it remove keys with undefined values, so we wouldn't end up setting https to an empty object, which was what the code was doing before. But I can remove this line.

Regarding testing, I tried to find a test using CA certificates, but couldn't find one, so I skipped it. Or do you mean just a unit test to check if the options passed to the Gitlab plugin are correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's correct, we don't really need it. My idea here was to use lodash merge because it remove keys with undefined values, so we wouldn't end up setting https to an empty object, which was what the code was doing before. But I can remove this line.

Thanks, merge is not descriptive towards that end, but let's just keep it then.

Regarding testing, I tried to find a test using CA certificates, but couldn't find one, so I skipped it. Or do you mean just a unit test to check if the options passed to the Gitlab plugin are correct?

Just the latter!

test/gitlab.js Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@webpro

I decided to do multiple checks inside the same test, because they are fairly simple, but I can also split them into multiple tests if you prefer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 🫡

@webpro webpro merged commit 7a3ce98 into release-it:main Jul 10, 2024
11 checks passed
@webpro
Copy link
Collaborator

webpro commented Jul 14, 2024

🚀 This pull request is included in v17.6.0. See Release 17.6.0 for release notes.

@webpro
Copy link
Collaborator

webpro commented Jul 14, 2024

Thanks @vonBrax!

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.

Allow insecure connections to self-hosted Gitlab instances
2 participants