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 an option to allow review app creation from forks #882

Merged
merged 21 commits into from
Mar 2, 2023

Conversation

yohann-bacha
Copy link
Contributor

@yohann-bacha yohann-bacha commented Feb 3, 2023

contributes to https://github.com/Scalingo/project-items/issues/68
depends on Scalingo/go-scalingo#300

need to do a go mod vendor after Scalingo/go-scalingo#300 before merging this

@aurelien-reeves-scalingo aurelien-reeves-scalingo changed the title feat: added the option to enable or disable review app creation forks feat: added the option to allow review app creation forks Feb 10, 2023
@aurelien-reeves-scalingo
Copy link
Contributor

Will be ready once go-scalingo is done: Scalingo/go-scalingo#300

@aurelien-reeves-scalingo aurelien-reeves-scalingo changed the title feat: added the option to allow review app creation forks feat: add an option to allow review app creation from forks Feb 15, 2023
@yohann-bacha yohann-bacha force-pushed the feat/review-apps/add-option-to-enable-from-forks branch from b050444 to 678c261 Compare February 21, 2023 09:40
@yohann-bacha yohann-bacha marked this pull request as ready for review February 21, 2023 09:49
Copy link
Contributor

@aurelien-reeves-scalingo aurelien-reeves-scalingo left a comment

Choose a reason for hiding this comment

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

We have to make sure other review-apps related commands puts some emphasis when dealing with forks

cmd/integration_link.go Show resolved Hide resolved
cmd/integration_link.go Outdated Show resolved Hide resolved
cmd/integration_link.go Outdated Show resolved Hide resolved
Comment on lines 498 to 503
forksAllowed := false
err = survey.AskOne(&survey.Confirm{
Message: "Allow review apps to be created from forks:",
Help: "Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues",
Default: forksAllowed,
}, &forksAllowed, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the use of io.Warning rather than the help mesage to make sure the warning is always seen. We could do the same here.

Also we could then use the same message defined in the constant reviewAppsFromForksSecurityWarning (warningSecurityMessageForAutomaticReviewAppsFromForks)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice idea, it has been done

Copy link
Contributor

Choose a reason for hiding this comment

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

it has been done

I don't see the change here. Am I missing something?

Copy link
Contributor Author

@yohann-bacha yohann-bacha Feb 23, 2023

Choose a reason for hiding this comment

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

Oh I got messed up, fixing it

Comment on lines 537 to 539
if forksAllowed {
io.Info("To bypass this security warning next time, you can provide the flag --aware-of-security-risks")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not encourage in any way to bypass a security notice. User could find that option on their own easily as it is properly documented

Suggested change
if forksAllowed {
io.Info("To bypass this security warning next time, you can provide the flag --aware-of-security-risks")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I think if the user has already told he's been aware of the security risks, we could give him the way to bypass it, because he's already aware. IMHO it would be a better experience

Copy link
Contributor

Choose a reason for hiding this comment

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

I would be in favor of security over UX in such case

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, the option to bypass the security warning is there mainly to prevent interactive mode in non-tty environment. Not to improve UX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well if you insist, I'll go with it :)

cmd/integration_link.go Outdated Show resolved Hide resolved
@@ -22,6 +22,8 @@ import (
)

var (
reviewAppsFromForksSecurityWarning = "Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues"
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, one final request for changes: addition of a link to the documentation as suggested on slack

Suggested change
reviewAppsFromForksSecurityWarning = "Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues"
reviewAppsFromForksSecurityWarning = "Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues. More info here: https://doc.scalingo.com/platform/app/review-apps#addons-collaborators-and-environment-variables"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, done

Comment on lines 498 to 503
forksAllowed := false
err = survey.AskOne(&survey.Confirm{
Message: "Allow review apps to be created from forks:",
Help: "Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues",
Default: forksAllowed,
}, &forksAllowed, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

it has been done

I don't see the change here. Am I missing something?

Default: forksAllowed,
}, &forksAllowed, nil)
if err != nil {
return params, err
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we try to always wrap errors into our own, using errgo.Notef for example (errgo when our custom error library is not available).

But I see here that there are other places like you did. I don't know if that was actually on purpose or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, in order to be consistent, I made this logic on all the integration_link.go file

…rity concerns as a warning

Signed-off-by: Yohann Bacha <[email protected]>
@@ -447,6 +492,19 @@ func interactiveCreate() (scalingo.SCMRepoLinkCreateParams, error) {
hoursBeforeDestroyOnStale := uint(hoursBeforeDestroyOnStale64)
params.HoursBeforeDeleteStale = &hoursBeforeDestroyOnStale
}

io.Warning("Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues")
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
io.Warning("Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues")
io.Warning(reviewAppsFromForksSecurityWarning)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's done

Copy link
Contributor

@aurelien-reeves-scalingo aurelien-reeves-scalingo 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.

I'll approve after a short qualification session

if err != nil {
errorQuit(err)
}
err = c.Set("allow-review-apps-from-forks", strconv.FormatBool(stillAllowed))
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears we actually allow review apps from forks even if the user answered "No".

This is because CheckAndFillParams only checks if allow-review-apps-from-forks is set, not its actual value.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am still facing the exact same issue

Did you submit a fix for that one?

To reproduce:

$ ./scalingo-cli -a test-app integration-link
Application: test-app (63691985884fef00111d2a6b)
Integration: GitHub (22a2daa4-b636-41c7-8b1b-9cd10e549fa5)
Linker: aurelien-reeves-scalingo

Repository: aurelien-reeves-scalingo/review-apps-securisation
Auto Deploy: ✘
Review Apps Deploy: ✔
	Destroy on Close: instantly
	Destroy on Stale: ✘
	Automatic creation from forks: ✘

$ ./scalingo-cli -a test-app integration-link-update --allow-review-apps-from-forks
  /!\  Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues. More info here: https://doc.scalingo.com/platform/app/review-apps#addons-collaborators-and-environment-variables
? Are your sure? No
-----> Your app 'test-app' integration link has been updated.

$ ./scalingo-cli -a test-app integration-link
Application: test-app (63691985884fef00111d2a6b)
Integration: GitHub (22a2daa4-b636-41c7-8b1b-9cd10e549fa5)
Linker: aurelien-reeves-scalingo

Repository: aurelien-reeves-scalingo/review-apps-securisation
Auto Deploy: ✘
Review Apps Deploy: ✔
	Destroy on Close: instantly
	Destroy on Stale: ✘
	Automatic creation from forks: ✔

We can see that the answer "No" to the update request did not prevent the update to be done

Copy link
Contributor

@aurelien-reeves-scalingo aurelien-reeves-scalingo left a comment

Choose a reason for hiding this comment

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

The "are you sure?" message still feels weird. We may find a way to improve it.

At the moment it looks like that:

$ scalingo -a test-app integration-link-create --allow-review-apps-from-forks https://github.com/aurelien-reeves-scalingo/review-apps-securisation
  /!\  Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues. More info here: https://doc.scalingo.com/platform/app/review-apps#addons-collaborators-and-environment-variables
? Are your sure? (y/N)

We may find a way to make it look more like that:

$ scalingo -a test-app integration-link-create --allow-review-apps-from-forks https://github.com/aurelien-reeves-scalingo/review-apps-securisation

  /!\  Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues. More info here: https://doc.scalingo.com/platform/app/review-apps#addons-collaborators-and-environment-variables

? Allow review apps from forks: (y/N)

cmd/integration_link.go Outdated Show resolved Hide resolved
Copy link
Contributor

@aurelien-reeves-scalingo aurelien-reeves-scalingo left a comment

Choose a reason for hiding this comment

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

I am still facing the issue when I am answering "No" to the confirmation, but the update is still done.

Also, the changes requested here seems to still be missing

if err != nil {
errorQuit(err)
}
err = c.Set("allow-review-apps-from-forks", strconv.FormatBool(stillAllowed))
Copy link
Contributor

Choose a reason for hiding this comment

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

I am still facing the exact same issue

Did you submit a fix for that one?

To reproduce:

$ ./scalingo-cli -a test-app integration-link
Application: test-app (63691985884fef00111d2a6b)
Integration: GitHub (22a2daa4-b636-41c7-8b1b-9cd10e549fa5)
Linker: aurelien-reeves-scalingo

Repository: aurelien-reeves-scalingo/review-apps-securisation
Auto Deploy: ✘
Review Apps Deploy: ✔
	Destroy on Close: instantly
	Destroy on Stale: ✘
	Automatic creation from forks: ✘

$ ./scalingo-cli -a test-app integration-link-update --allow-review-apps-from-forks
  /!\  Only allow automatic review apps deployments from forks if you trust the owners of those forks, as this could lead to security issues. More info here: https://doc.scalingo.com/platform/app/review-apps#addons-collaborators-and-environment-variables
? Are your sure? No
-----> Your app 'test-app' integration link has been updated.

$ ./scalingo-cli -a test-app integration-link
Application: test-app (63691985884fef00111d2a6b)
Integration: GitHub (22a2daa4-b636-41c7-8b1b-9cd10e549fa5)
Linker: aurelien-reeves-scalingo

Repository: aurelien-reeves-scalingo/review-apps-securisation
Auto Deploy: ✘
Review Apps Deploy: ✔
	Destroy on Close: instantly
	Destroy on Stale: ✘
	Automatic creation from forks: ✔

We can see that the answer "No" to the update request did not prevent the update to be done

cmd/integration_link.go Outdated Show resolved Hide resolved
@Soulou
Copy link
Member

Soulou commented Mar 2, 2023

@aurelien-reeves-scalingo can you merge and release this week?

@yohann-bacha yohann-bacha merged commit 48813e6 into master Mar 2, 2023
@yohann-bacha yohann-bacha deleted the feat/review-apps/add-option-to-enable-from-forks branch March 2, 2023 10:19
@aurelien-reeves-scalingo
Copy link
Contributor

@aurelien-reeves-scalingo can you merge and release this week?

I'll release it tomorrow 👌

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.

3 participants