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

Bug 1859874: Add basic engine URL validation #3948

Conversation

gekorob
Copy link
Contributor

@gekorob gekorob commented Jul 23, 2020

Add a basic URL validator to avoid adding urls with no
scheme or scheme different from https.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1859874

Signed-off-by: Roberto Ciatti rciatti@redhat.com

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jul 23, 2020
@openshift-ci-robot
Copy link
Contributor

@gekorob: This pull request references Bugzilla bug 1859874, which is invalid:

  • expected the bug to target the "4.5.z" release, but it targets "---" instead
  • expected Bugzilla bug 1859874 to depend on a bug targeting a release in 4.6.0, 4.6.z and in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but no dependents were found

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1859874: Add basic engine URL validation

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gekorob
Copy link
Contributor Author

gekorob commented Jul 23, 2020

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@gekorob: This pull request references Bugzilla bug 1859874, which is invalid:

  • expected Bugzilla bug 1859874 to depend on a bug targeting a release in 4.6.0, 4.6.z and in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but no dependents were found

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gekorob gekorob force-pushed the ovirt-installer-basic-url-validations branch 2 times, most recently from e24af44 to 982f9d4 Compare July 23, 2020 15:23
Copy link
Contributor

@dougsland dougsland left a comment

Choose a reason for hiding this comment

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

Just small comments. LGTM

pkg/asset/installconfig/ovirt/validaton.go Outdated Show resolved Hide resolved
pkg/asset/installconfig/ovirt/validaton.go Outdated Show resolved Hide resolved
@Gal-Zaidman
Copy link
Contributor

/retest

@gekorob
Copy link
Contributor Author

gekorob commented Jul 28, 2020

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@gekorob: This pull request references Bugzilla bug 1859874, which is invalid:

  • expected dependent Bugzilla bug 1861251 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is NEW instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gekorob gekorob force-pushed the ovirt-installer-basic-url-validations branch from 982f9d4 to 34c5161 Compare July 28, 2020 13:36
@dougsland
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 28, 2020
@dougsland
Copy link
Contributor

Tested locally the change and it works. Waiting the bugzilla label ack to add the approve

@openshift-bot
Copy link
Contributor

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

@openshift-ci-robot
Copy link
Contributor

@openshift-bot: This pull request references Bugzilla bug 1859874, which is invalid:

  • expected dependent Bugzilla bug 1861251 to be in one of the following states: VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), but it is ON_QA instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/bugzilla refresh

Recalculating validity in case the underlying Bugzilla bug has changed.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gekorob
Copy link
Contributor Author

gekorob commented Jul 29, 2020

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Jul 29, 2020
@openshift-ci-robot
Copy link
Contributor

@gekorob: This pull request references Bugzilla bug 1859874, which is valid. The bug has been updated to refer to the pull request using the external bug tracker.

6 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.z) matches configured target release for branch (4.5.z)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
  • dependent bug Bugzilla bug 1861251 is in the state VERIFIED, which is one of the valid states (VERIFIED, RELEASE_PENDING, CLOSED (ERRATA))
  • dependent Bugzilla bug 1861251 targets the "4.6.0" release, which is one of the valid target releases: 4.6.0, 4.6.z
  • bug has dependents

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot removed the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Jul 29, 2020
@dougsland
Copy link
Contributor

ci/prow/e2e-ovirt — Job succeeded.

@dougsland
Copy link
Contributor

/approve

@dougsland
Copy link
Contributor

/assign @rgolangh

Comment on lines 133 to 140
url, err := url.ParseRequestURI(urlStr)
if err != nil {
return errors.Errorf("The specified URL is invalid, got %s", urlStr)
}

if url.Scheme != "https" {
return errors.Errorf("The only URL scheme accepted is https, but got %s", url.Scheme)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

also this entire function can be made a little easier to read by early error return.

uri, ok := val.(string)
if !ok {
  return invalid expected string
}
return validate.URIWithProtocol(uri, "https")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @abhinavdahiya I didn't know about URIWithProtocol, great suggestion. I've replaced the code.

}{
{
url: "engine.example.com",
expectSuccess: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

test for actual errors and not just error yes/no

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed expectations using the Error returned by URIWithProtocol, hope I understood correctly your point.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 31, 2020
@gekorob
Copy link
Contributor Author

gekorob commented Jul 31, 2020

/retest

@dougsland
Copy link
Contributor

LGTM. Waiting feedback from @abhinavdahiya

Copy link
Contributor

@abhinavdahiya abhinavdahiya left a comment

Choose a reason for hiding this comment

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

/approve

func validURL(val interface{}) error {
uri, ok := val.(string)
if !ok {
return fmt.Errorf("cannot check url validity on type %v", reflect.TypeOf(val).Name())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("cannot check url validity on type %v", reflect.TypeOf(val).Name())
return fmt.Errorf("cannot check url validity on type %T", val)

https://golang.org/pkg/fmt/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx for the suggestion.

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, dougsland

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 31, 2020
@dougsland
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels Jul 31, 2020
@dougsland
Copy link
Contributor

My only comment: If possible, please squash the patches. Otherwise, looks good to me.

Add a basic URL validator to avoid adding urls with no
scheme or scheme different from https

Signed-off-by: Roberto Ciatti <rciatti@redhat.com>
@gekorob gekorob force-pushed the ovirt-installer-basic-url-validations branch from c4a16e9 to 3f71c8b Compare August 10, 2020 06:40
@Gal-Zaidman
Copy link
Contributor

/test e2e-ovirt

2 similar comments
@Gal-Zaidman
Copy link
Contributor

/test e2e-ovirt

@dougsland
Copy link
Contributor

/test e2e-ovirt

@dougsland
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 10, 2020
@jwforres jwforres added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Aug 20, 2020
@openshift-merge-robot openshift-merge-robot merged commit d104265 into openshift:release-4.5 Aug 20, 2020
@openshift-ci-robot
Copy link
Contributor

@gekorob: All pull requests linked via external trackers have merged: openshift/installer#3948. Bugzilla bug 1859874 has been moved to the MODIFIED state.

In response to this:

Bug 1859874: Add basic engine URL validation

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants