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: org belonging enforcment - RK-19484 #110

Merged
merged 4 commits into from
Sep 6, 2023
Merged

Conversation

gosharo
Copy link
Contributor

@gosharo gosharo commented Jul 25, 2023

Signed-off-by: Gosha [email protected]

Pull Request

Description

This will give Piper the ability to enforce the organizational belonging of Git event sender/creator.

Checklist

Before submitting this pull request, please ensure that you have completed the following tasks:

@sonariorobot sonariorobot changed the title feat: org belonging enforcment feat: org belonging enforcment - RK-19483 Jul 25, 2023
@sonariorobot sonariorobot changed the title feat: org belonging enforcment feat: org belonging enforcment - RK-19484 Jul 25, 2023
@gosharo gosharo requested a review from ElDuderinos July 25, 2023 02:37
@gosharo gosharo added the DeployEnforcer/MergeOnceApproved Auto merge and clean branch once passed all checks label Jul 25, 2023
@gosharo gosharo requested a review from EliRookout July 25, 2023 02:39
}
}

if c.cfg.EnforceOrgBelonging && webhookPayload.OwnerID != c.cfg.OrgID {

Choose a reason for hiding this comment

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

What's the default here for the int64? Nil? 0? Check that they aren't the default

Copy link
Contributor Author

@gosharo gosharo Jul 27, 2023

Choose a reason for hiding this comment

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

in go var int64 is set to zero automatically ..
also user.GetID return 0 if not found

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and if the first one is false, the second not evaluated

Copy link

@ElDuderinos ElDuderinos Jul 27, 2023

Choose a reason for hiding this comment

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

So if ownerid is 0 we don't want the enforcement to pass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohhh you mean webhookPayload.OwnerID...
we are getting it from the webhook payload.. and if it missing, then it could be passed..
what are your suggestions ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can check something like
c.cfg.EnforceOrgBelonging && webhookPayload.OwnerID != 0 && webhookPayload.OwnerID != c.cfg.OrgID

Choose a reason for hiding this comment

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

should be

c.cfg.EnforceOrgBelonging && (webhookPayload.OwnerID == 0 || webhookPayload.OwnerID != c.cfg.OrgID)

Cause if it's 0 and you need enforcement then you can't check enforcement validity and thus fail it.

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

@gosharo gosharo requested a review from ElDuderinos July 27, 2023 18:27
Signed-off-by: Gosha <[email protected]>
@gosharo gosharo merged commit ff9e957 into main Sep 6, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DeployEnforcer/MergeOnceApproved Auto merge and clean branch once passed all checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants