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

[match] nuke now supports filtering by specific certificates #19584

Merged
merged 5 commits into from
Nov 9, 2021

Conversation

joshdholtz
Copy link
Member

@joshdholtz joshdholtz commented Nov 5, 2021

Motivation and Context

Match's nuke has always nuke all certificate and provisioning profiles without giving an option to nuke only a subset with filtering. This behavior worked out great unless you had a lot of certificates and profiles that were good and there were only a few that were bad or expired that you wanted to revoke and delete.

This new behavior allows optional filtering by one to many certificates which will filter the only to those specified certificates and the profiles that use them.

Description

  • Adds a new filter_by_cert method after prepare_list and before print_tables that offers user the option to filter by certificate
    • Skips if :force is set to true
    • Skips if less than 2 certificates
    • Prints table of certificates that to choose
    • Rejects portal certificates from list that weren't selects
    • Rejects portal profiles from list that don't use selected certificates
    • Iterates over storage files that don't match with selected certificates or associated profiles
[15:22:36]: Fetching certificates and profiles...                                                                                          
                                                                                                                                           
+--------+----------------------+------------+-------------+------------+                                                                  
|                   Certificates that can be revoked                    |                                                                  
+--------+----------------------+------------+-------------+------------+                                                                  
| Option | Name                 | ID         | Type        | Expires    |                                                                  
+--------+----------------------+------------+-------------+------------+                                                                  
| 1      | Apple Distribution:  | 297G643675 | Certificate | 2022-08-25 |                                                                  
|        | Josh Holtz           |            |             |            |                                                                  
| 2      | Apple Distribution:  | YS3CC9B4F9 | Certificate | 2022-08-25 |                                                                  
|        | Josh Holtz           |            |             |            |                                                                  
+--------+----------------------+------------+-------------+------------+                                                                  
                                                                                                                                           
[15:22:38]: Do you want to nuke specific certificates and their associated profiles? (y/n)                                                 
y                                                                                                                                          
[15:22:43]: Enter the "Option" number(s) from the table above? (comma-separated)                                                           
1                                                                                                                                          
                                                                                                                                           
+---------------------------+------------+-------------+------------+                                                                      
|             Certificates that are going to be revoked             |                                                                      
+---------------------------+------------+-------------+------------+                                                                      
| Name                      | ID         | Type        | Expires    |                                                                      
+---------------------------+------------+-------------+------------+                                                                      
| Apple Distribution: Josh  | 297G643675 | Certificate | 2022-08-25 |                                                                      
| Holtz                     |            |             |            |                                                                      
+---------------------------+------------+-------------+------------+                                                                      
                                                                                                                                           
+-------------------------+------------+--------+---------------+------------+                                                             
|             Provisioning Profiles that are going to be revoked             |                                                             
+-------------------------+------------+--------+---------------+------------+                                                             
| Name                    | ID         | Status | Type          | Expires    |                                                             
+-------------------------+------------+--------+---------------+------------+                                                             
| match AppStore          | 5299GP27D9 | ACTIVE | IOS_APP_STORE | 2022-08-25 |                                                             
| com.joshholtz.CrunchyG  |            |        |               |            |                                                             
| IF                      |            |        |               |            |

Testing Steps

Update Gemfile and run bundle install, bundle update fastlane, or bundle update

gem "fastlane", :git => "https://github.com/fastlane/fastlane.git", :branch => "joshdholtz-nuke-by-certificate"

@google-cla google-cla bot added the cla: yes label Nov 5, 2021
Copy link
Member

@crazymanish crazymanish left a comment

Choose a reason for hiding this comment

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

this looks awesome... 👏 🚀

Comment on lines 182 to 184
# Force will continue to revoke and delete all certificates and profiles
return if self.params[:force]
return if self.certs.count < 2
Copy link
Member

Choose a reason for hiding this comment

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

i think, we should early return if this func will be running on CI, because users cant input/select specific certificates on CI? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point 👍.
Would return unless UI.interactive? do the job?
If it does, other possibility would be check if we're in interactive mode in run

prepare_list
filter_by_cert if UI.interactive?
print_tables

Copy link
Contributor

@lucgrabowski lucgrabowski left a comment

Choose a reason for hiding this comment

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

LGTM 🚀🚀🚀

Comment on lines 182 to 184
# Force will continue to revoke and delete all certificates and profiles
return if self.params[:force]
return if self.certs.count < 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Good point 👍.
Would return unless UI.interactive? do the job?
If it does, other possibility would be check if we're in interactive mode in run

prepare_list
filter_by_cert if UI.interactive?
print_tables

}))
puts("")

if UI.confirm("Do you want to nuke specific certificates and their associated profiles?")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to add an explanation that Declining will nuke all the listed certificates and their associated profiles

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this idea!

Also, @lucgrabowski... Do you mind sending me an email over at me AT joshholtz DOT com? 😇 Tried looking for contact info for you on your GitHub profile but couldn't find any 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @joshdholtz, sure, I'll send you an email.

@joshdholtz joshdholtz force-pushed the joshdholtz-nuke-by-certificate branch from 6b1e68a to 64859fe Compare November 9, 2021 02:01
@joshdholtz joshdholtz merged commit eaa7b9a into master Nov 9, 2021
@joshdholtz joshdholtz deleted the joshdholtz-nuke-by-certificate branch November 9, 2021 17:00
@fastlane-bot
Copy link

Hey @joshdholtz 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@fastlane-bot
Copy link

Congratulations! 🎉 This was released as part of fastlane 2.198.0 🚀

@fastlane fastlane locked and limited conversation to collaborators Jan 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants