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

Hostname check with DNS or not #276

Conversation

alexanderkjall
Copy link
Contributor

add an environment variable to control if the hostname check should be performed with a dns resolution or not.

adevinta/vulcan-types#142 needs to be merged and released before this can be evaluated I guess :)

pkg/api/asset.go Outdated
@@ -67,8 +68,14 @@ func (a Asset) Validate() error {

switch a.AssetType.Name {
case "Hostname":
if !types.IsHostname(a.Identifier) {
return errors.Validation("Identifier is not a valid Hostname")
if os.Getenv("VULCAN_HOSTNAME_VALIDATION_WITH_DNS") == "false" {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't directly access env vars in the logic of the program.
In order to add a config option you need to:

  1. Add it to the config file that maps env vars to parameters in the config file
    I think there isn't any section that makes sense to add this new param, so I would add a new section, something like this:
[assets]
dns_hostname_validaton = "$DNS_HOSTNAME_VALIDATION"
  1. Map the value in the run script of the container by adding something like this:
export DNS_HOSTNAME_VALIDATION=${DNS_HOSTNAME_VALIDATION:-true}
  1. Add the new section in the struct representing the configuration of the api

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review, I updated the branch and tried to apply this feedback.

Alexander Kjäll added 2 commits December 18, 2023 15:38
…tion, and instead use the viper library for that
@alexanderkjall alexanderkjall force-pushed the add-config-check-for-hostname-dns-verification branch from f3fb001 to 666953a Compare December 18, 2023 14:46
@manelmontilla
Copy link
Contributor

manelmontilla commented Jan 8, 2024

I added comment with a suggestion to change a little bit the approach.
Apart from that some tests are not parsing, I know is hard to know if the tests are passing or not as the travis builds are not running in the forks. I'll try to add you as collaborator to the vulcan repos, it's not straightforward because someone that is admin of the Adevinta org (which I'm not) must send the invite, so in the future you should be able to create PR's in the repos directly and see the results of the build.
Meanwhile, could you run the tests locally?
To do so, you just need to:

  1. Start the persistence layer locally by executing:
cd db
./persistence-start.sh
./flyway-migrate.sh

Note: You will need to have docker installed.

  1. Run the go test in the usual way by executing the following from the root of the repo:
go test ./...

cmd/vulcan-api/commands.go Outdated Show resolved Hide resolved
config.toml Outdated Show resolved Hide resolved
pkg/api/endpoint/assets.go Outdated Show resolved Hide resolved
Alexander Kjäll added 2 commits January 16, 2024 08:35
@alexanderkjall
Copy link
Contributor Author

Any update on this one?

1 similar comment
@alexanderkjall
Copy link
Contributor Author

Any update on this one?

@kozmic
Copy link

kozmic commented Apr 4, 2024

Now that the adevinta/vulcan-types#142 has been merged, could this PR be reviewed and merged @manelmontilla ?

@jesusfcr
Copy link
Contributor

Fixed and merged #317

@jesusfcr jesusfcr closed this Apr 24, 2024
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.

4 participants