-
Notifications
You must be signed in to change notification settings - Fork 42
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
Implement profile update #1566
Implement profile update #1566
Conversation
0bbc9a1
to
1dde87f
Compare
1dde87f
to
ba7bb62
Compare
Manual testing - toggling alerts on/offCreated a simple profile with only one rule: version: v1
type: profile
name: acme-github-profile
context:
provider: github
alert: "off"
remediate: "off"
repository:
- type: secret_scanning
def:
enabled: true enrolled two repositories. Then, I updated the profile to enable alerts version: v1
type: profile
name: acme-github-profile
context:
provider: github
alert: "on"
remediate: "off"
repository:
- type: secret_scanning
def:
enabled: true I applied the changes with the following: minder profile update -f <path/to/profile> I can see the profile was updated:
Toggling the alerts on and off subsequently works as expected. |
Manual testing - adding rulesI added a rule to the aforementioned profile: version: v1
type: profile
name: acme-github-profile
context:
provider: github
alert: "on"
remediate: "off"
repository:
- type: secret_scanning
def:
enabled: true
- type: secret_push_protection
def:
enabled: true The update was done as follows:
the output of the command already suggests that the rule was added. But let's verify the status:
As we can see, it adds the new rule as expected. Also note that the usage of these rules was persisted in the database:
As a final test, I added the |
Manual testing - removing rulesWith the aforementioned modified profile, I decided to remove the rule I just added. Which seemed to happen successfully:
Upon further inspection, it seems that we don't remove the rule evaluations from the status. This has to be fixed We also don't yet remove the usage from the This also has to be fixed Further work is required. I'll keep this up-to-date. |
ba7bb62
to
f81c523
Compare
The latest PR ensures that we can also remove instantiation of the rules. This works and reflects in the database. What's missing is cleaning up rule evaluations. |
The latest commit fixes the last issues I saw. |
Found another issue, wait up:
|
Alright! This is a summary of what was missing: We didn't have a unique index that would allow us to ensure we only have a single entity+profile I had to use a |
69143d1
to
3d287c1
Compare
I rebased and added missing licenses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall seems to work well, some nits and questions inline
profiles, err := s.store.GetProfileByProjectAndID(ctx, db.GetProfileByProjectAndIDParams{ | ||
prof, err := getProfilePBFromDB(ctx, parsedProfileID, entityCtx, s.store) | ||
if err != nil { | ||
if errors.Is(err, sql.ErrNoRows) || strings.Contains(err.Error(), "not found") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when do we get the second case? Wouldn't it be better to catch that issue by Postgres error code if that error comes directly from Postgres?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "not found" is not a postgres error. I just didn't create a specialized error for this 😕
3d287c1
to
3783904
Compare
6a88d39
to
e481648
Compare
@rdimitrov and I are gonna go through this tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holding off this until tomorrow since there are a few issues left to fix 👍
e481648
to
bf9cc6c
Compare
This implements the profile update method in the minder server. This was done last as it's kinda complex... as you can tell from the PR. We have to verify that the new profile is valid, that certain values like the project, name and provider don't change. Then we update the rules, and clean up the unused ones. And keep the instantiations in check. This, however, will be a very nice usability improvement. This also adds a profile update command
bf9cc6c
to
28a9c1c
Compare
done! Now this is up with the latest changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I've given it a go again today trying various scenarios but I did not found anything worrying so far 🚀
This implements the profile update method in the minder server.
This was done last as it's kinda complex... as you can tell from the PR.
We have to verify that the new profile is valid, that certain values like the
project, name and provider don't change. Then we update the rules, and clean up
the unused ones. And keep the instantiations in check.
This, however, will be a very nice usability improvement.