-
Notifications
You must be signed in to change notification settings - Fork 635
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 docs around package scanning and notify user of infected package upload. #13235
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,11 @@ private void SetFilterHosts(object obj) | |
// The results of the last synchronization with the package manager server | ||
public List<PackageManagerSearchElement> LastSync { get; set; } | ||
|
||
/// <summary> | ||
/// Stores a list of latest infected package versions published by the current user, if any. | ||
/// </summary> | ||
public ObservableCollection<PackageManagerSearchElement> InfectedPackages { get; set; } | ||
|
||
/// <summary> | ||
/// SortingKey property | ||
/// </summary> | ||
|
@@ -387,7 +392,7 @@ public PackageSearchState SearchState | |
/// appears at the base of the window. This command fires when the user clicks to dismiss | ||
/// one of these toast notifications. | ||
/// </summary> | ||
public DelegateCommand<object> ClearDownloadToastNotificationCommand { get; set; } | ||
public DelegateCommand<object> ClearToastNotificationCommand { get; set; } | ||
|
||
|
||
/// <summary> | ||
|
@@ -408,6 +413,7 @@ public IPreferences Preferences | |
internal PackageManagerSearchViewModel() | ||
{ | ||
SearchResults = new ObservableCollection<PackageManagerSearchElementViewModel>(); | ||
InfectedPackages = new ObservableCollection<PackageManagerSearchElement>(); | ||
MaxNumSearchResults = 35; | ||
SearchDictionary = new SearchDictionary<PackageManagerSearchElement>(); | ||
ClearCompletedCommand = new DelegateCommand(ClearCompleted, CanClearCompleted); | ||
|
@@ -416,7 +422,7 @@ internal PackageManagerSearchViewModel() | |
SetSortingDirectionCommand = new DelegateCommand<object>(SetSortingDirection, CanSetSortingDirection); | ||
ViewPackageDetailsCommand = new DelegateCommand<object>(ViewPackageDetails); | ||
ClearSearchTextBoxCommand = new DelegateCommand<object>(ClearSearchTextBox); | ||
ClearDownloadToastNotificationCommand = new DelegateCommand<object>(ClearDownloadToastNotification); | ||
ClearToastNotificationCommand = new DelegateCommand<object>(ClearToastNotification); | ||
SearchText = string.Empty; | ||
SortingKey = PackageSortingKey.LastUpdate; | ||
SortingDirection = PackageSortingDirection.Descending; | ||
|
@@ -543,17 +549,28 @@ public void ClearSearchTextBox(object obj) | |
/// one of these toast notifications. | ||
/// </summary> | ||
/// <param name="obj"></param> | ||
public void ClearDownloadToastNotification(object obj) | ||
public void ClearToastNotification(object obj) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is API breaking but I guess you decided to break it intentionally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes to make this function a bit more generic |
||
{ | ||
if (!(obj is PackageDownloadHandle packageDownloadHandle)) return; | ||
if (obj is PackageDownloadHandle packageDownloadHandle) | ||
{ | ||
|
||
PackageDownloadHandle packageDownloadHandleToRemove = PackageManagerClientViewModel.Downloads | ||
.FirstOrDefault(x => x.Id == packageDownloadHandle.Id); | ||
PackageDownloadHandle packageDownloadHandleToRemove = PackageManagerClientViewModel.Downloads | ||
.FirstOrDefault(x => x.Id == packageDownloadHandle.Id); | ||
|
||
if (packageDownloadHandleToRemove == null) return; | ||
if (packageDownloadHandleToRemove == null) return; | ||
|
||
PackageManagerClientViewModel.Downloads.Remove(packageDownloadHandleToRemove); | ||
RaisePropertyChanged(nameof(Downloads)); | ||
PackageManagerClientViewModel.Downloads.Remove(packageDownloadHandleToRemove); | ||
RaisePropertyChanged(nameof(Downloads)); | ||
} | ||
else if (obj is PackageManagerSearchElement packageSearchElement) | ||
{ | ||
PackageManagerSearchElement packageInfectedToRemove = this.InfectedPackages | ||
.FirstOrDefault(x => x.InfectedPackageName == packageSearchElement.InfectedPackageName); | ||
|
||
this.InfectedPackages.Remove(packageInfectedToRemove); | ||
RaisePropertyChanged(nameof(InfectedPackages)); | ||
} | ||
return; | ||
} | ||
|
||
/// <summary> | ||
|
@@ -671,9 +688,26 @@ public void RefreshAndSearchAsync() | |
} | ||
this.SearchState = HasNoResults ? PackageSearchState.NoResults : PackageSearchState.Results; | ||
} | ||
RefreshInfectedPackages(); | ||
} | ||
, TaskScheduler.FromCurrentSynchronizationContext()); // run continuation in ui thread | ||
|
||
} | ||
|
||
internal void RefreshInfectedPackages() | ||
{ | ||
var infectedPkgs = PackageManagerClientViewModel.GetInfectedPackages(); | ||
infectedPkgs.Sort((e1, e2) => e1.InfectedPackageCreationDate.CompareTo(e2.InfectedPackageCreationDate)); | ||
|
||
this.InfectedPackages.Clear(); | ||
foreach (var pkg in infectedPkgs) { | ||
this.InfectedPackages.Add(pkg); | ||
|
||
// Limiting the infected packages list to 3. As the packages are resolved other unresolved packages will be displayed. | ||
if (this.InfectedPackages.Count() == 3) | ||
{ | ||
break; | ||
} | ||
} | ||
} | ||
|
||
internal void AddToSearchResults(PackageManagerSearchElementViewModel element) | ||
|
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.
Would you remind me why do we need to look at each version here? I thought we only need to check the latest version of each package
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 API will return all packages with last uploaded version, so 1 version per package only.