forked from chocolatey/ChocolateyGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolatey#770) Add ability to view install arguments
This allows the viewing of the contents of the .arguments file, which is stored on a per package version, and contains the arguments that were passed into the choco install command for that package. This file is encrypted, and can't be viewed directly, but this allows decryption of the contents for viewing. Co-authored-by: steviecoaster <[email protected]>
- Loading branch information
1 parent
2aab41b
commit 1fafb45
Showing
8 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Source/ChocolateyGui.Common.Windows/Services/IPackageArgumentsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright company="Chocolatey" file="IPackageArgumentsService.cs"> | ||
// Copyright 2017 - Present Chocolatey Software, LLC | ||
// Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace ChocolateyGui.Common.Windows.Services | ||
{ | ||
public interface IPackageArgumentsService | ||
{ | ||
string DecryptPackageArgumentsFile(string id, string version); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright company="Chocolatey" file="PackageArgumentsService.cs"> | ||
// Copyright 2017 - Present Chocolatey Software, LLC | ||
// Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using chocolatey; | ||
using chocolatey.infrastructure.adapters; | ||
using ChocolateyGui.Common.Properties; | ||
using ChocolateyGui.Common.Providers; | ||
using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; | ||
using ILogger = Serilog.ILogger; | ||
|
||
namespace ChocolateyGui.Common.Windows.Services | ||
{ | ||
public class PackageArgumentsService : IPackageArgumentsService | ||
{ | ||
private static readonly ILogger Logger = Serilog.Log.ForContext<PackageArgumentsService>(); | ||
private readonly IEncryptionUtility _encryptionUtility; | ||
private readonly IFileSystem _fileSystem; | ||
private readonly IChocolateyConfigurationProvider _chocolateyConfigurationProvider; | ||
|
||
public PackageArgumentsService(IEncryptionUtility encryptionUtility, IFileSystem fileSystem, IChocolateyConfigurationProvider chocolateyConfigurationProvider) | ||
{ | ||
_encryptionUtility = encryptionUtility; | ||
_fileSystem = fileSystem; | ||
_chocolateyConfigurationProvider = chocolateyConfigurationProvider; | ||
} | ||
|
||
public string DecryptPackageArgumentsFile(string id, string version) | ||
{ | ||
var argumentsPath = _fileSystem.combine_paths(_chocolateyConfigurationProvider.ChocolateyInstall, ".chocolatey", "{0}.{1}".format_with(id, version)); | ||
var argumentsFile = _fileSystem.combine_paths(argumentsPath, ".arguments"); | ||
|
||
// Get the arguments decrypted in here and return them | ||
try | ||
{ | ||
if (_fileSystem.file_exists(argumentsFile)) | ||
{ | ||
return _encryptionUtility.decrypt_string(_fileSystem.read_file(argumentsFile)); | ||
} | ||
|
||
return Resources.PackageView_UnableToFindArgumentsFile.format_with(version, id); | ||
} | ||
catch (Exception ex) | ||
{ | ||
var message = Resources.Application_PackageArgumentsError.format_with(version, id); | ||
Logger.Error(ex, message); | ||
return message; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Source/ChocolateyGui.Common/Properties/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters