-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
Add secrets search and bump DotUtils.MsBuild.BinlogRedactor.SensitiveDataDetector version #829
Add secrets search and bump DotUtils.MsBuild.BinlogRedactor.SensitiveDataDetector version #829
Conversation
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.
I love this!
Can this be added to list of sample searches? MSBuildStructuredLog/src/StructuredLogViewer/Controls/BuildControl.xaml.cs Lines 633 to 646 in fa3c09e
![]() |
var haystack = file.Value; | ||
var resultsInFile = haystack.Find(searchText); | ||
if (resultsInFile.Count > 0) | ||
if (!string.IsNullOrEmpty(searchText) && searchText.StartsWith("$secret")) |
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.
this condition will run for every file, and it doesn't change. How about we extract a bool above the foreach and just check it here?
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.
moved
Very nice! I left a couple small comments but otherwise it's good to go! |
@@ -1023,24 +1022,19 @@ private object FindInFiles(string searchText, int maxResults, CancellationToken | |||
{ | |||
var results = new List<(string, IEnumerable<(int, string)>)>(); | |||
|
|||
NodeQueryMatcher notQueryMatcher = new NodeQueryMatcher(searchText); |
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.
did you mean nodeQueryMatcher
?
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.
I fixed it in main
@@ -1023,24 +1022,19 @@ private object FindInFiles(string searchText, int maxResults, CancellationToken | |||
{ | |||
var results = new List<(string, IEnumerable<(int, string)>)>(); | |||
|
|||
NodeQueryMatcher notQueryMatcher = new NodeQueryMatcher(searchText); | |||
bool isSecretsSearch = !string.IsNullOrEmpty(searchText) && searchText.StartsWith("$secret"); |
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.
you can also check for nodeQueryMatcher.TypeKeyword == "secret"
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.
Very nice, thanks!
@YuliiaKovalova - do you want to promete the functionality on the viewer help? Probably here?: https://github.com/KirillOsenkov/MSBuildLog/blob/6f87e14be0eb1a7cfe7c40e912b96b9ce0cf0301/index.html#L185-L191 |
One todo would be to investigate adding parallelism to secret detection because right now it's really slow on real-life binlogs, even moderately sized. Takes over two minutes on a 5 MB binlog I use often. I think a judicious use of Task.Run() will really make things better here. You can maybe spawn one task per string, and one task per file, then just foreach the tasks and do task.Wait() on each of them. No need for async as only one thread will be blocked (the one where the computation happens) |
I filed #832 |
Fixes
#823
Context
This change adds a support of a new search key word "$secret" that allows to detect all the suspicious tree entries, based on the capabilities of this library MSBuild.BinlogRedactor.
MSBuild.BinlogRedactor is already used for secrets reduction functionality, but it this context it's possible to check the presence of the secrets on fly
![{4CD40D35-CD93-4195-B83B-30873E35C1D2}](https://private-user-images.githubusercontent.com/95473390/381949671-882ff8ab-7488-498c-a888-89d57874aaa5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2OTQ2MzEsIm5iZiI6MTczOTY5NDMzMSwicGF0aCI6Ii85NTQ3MzM5MC8zODE5NDk2NzEtODgyZmY4YWItNzQ4OC00OThjLWE4ODgtODlkNTc4NzRhYWE1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA4MjUzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTg4MTY5ZGJiN2I0MWQ0MzFiNTZlOTE3M2YwYjZlNzJjNjhlNTQ4ZmEzNTk4MjNhZDE4NzczN2E0YjVlNjlhNzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.YW2Yx26sZ359X4jQVlg6kTarKk5ykyF6taMFsi12E_Y)
$secret not(SensitiveDataKind) statement is supported here:
![{E743D083-2878-4655-AACF-711D9A8E6610}](https://private-user-images.githubusercontent.com/95473390/381950025-7462c24a-8dfb-4b74-bf5d-3b1772c3c8ba.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2OTQ2MzEsIm5iZiI6MTczOTY5NDMzMSwicGF0aCI6Ii85NTQ3MzM5MC8zODE5NTAwMjUtNzQ2MmMyNGEtOGRmYi00Yjc0LWJmNWQtM2IxNzcyYzNjOGJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA4MjUzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRkNDlmN2NhNmRmNjUzYTVhNjA0MDQ4YWQwMzYyMThmY2MxYzRjNzYyODUwYTk4MWM0ZDU3OWNhYjMxNTg0YTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.HqUCR_Lz8k9s9kOPuMeZoPWK5ULYgA7iGmvEa1lp3YU)
It's possible to use the new keyword on 2 tabs:
![{12CCFBFD-AC63-4A06-B1F7-86948D7B721A}](https://private-user-images.githubusercontent.com/95473390/381950419-b15743fa-a1e7-4ccc-907b-82c2dd842ee9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2OTQ2MzEsIm5iZiI6MTczOTY5NDMzMSwicGF0aCI6Ii85NTQ3MzM5MC8zODE5NTA0MTktYjE1NzQzZmEtYTFlNy00Y2NjLTkwN2ItODJjMmRkODQyZWU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA4MjUzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ5MDI4N2Q2NTk5YzE3MTJlZTdkZmUyMGQ1ZDAyYjc4ZTJhOTNmN2ViM2RkOWI2NWJhODVhODhiMWMwOTRhNDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.y4saZhxoVdLjXOKLdtVgJ23yOgjtkkQ7kzIClE66mX0)
"Search Log"
"Find in Files"
![{ED9BC1B4-EBC7-4979-B8E2-097B9A01AB53}](https://private-user-images.githubusercontent.com/95473390/381950227-9183422a-a14d-4b0c-89e0-78ec419d5c3f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2OTQ2MzEsIm5iZiI6MTczOTY5NDMzMSwicGF0aCI6Ii85NTQ3MzM5MC8zODE5NTAyMjctOTE4MzQyMmEtYTE0ZC00YjBjLTg5ZTAtNzhlYzQxOWQ1YzNmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA4MjUzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBkNDFjYjc0NDgxNGQzMzgyNjRhYWNkZTUzMmRhYmJhMWUzMTU2ZGIwMDVjOThkNjk5ZGJiZWIzM2QzODEyNTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0._8U9Po-m4GU_ETJL_-hVg_CuE5UHZbZqwOinLekm_pw)
Changes made
A new SecretsSearch class was implemented based on ISearchExtension interface.
To make this functionality available on "Find in Files" tab, the method was extended
MSBuildStructuredLog/src/StructuredLogViewer/Controls/BuildControl.xaml.cs
Line 1022 in 6e4fc91
msbuild_logWithFalseSecrets.zip