Users/jstatia/fix plugin switch mappings#159
Merged
elantiguamsft merged 6 commits intomainfrom Jan 28, 2026
Merged
Conversation
…ConfigurationProvider The Options dictionary in plugins uses 'option-name' -> 'description' format, but CommandLineConfigurationProvider expects switch mappings in '--option-name' -> 'configKey' format. This was causing 'The switch mappings contain an invalid switch' errors when running any plugin command (like indirect-sign).
…ecution Added comprehensive integration tests that: - Validate all plugin option keys can be converted to valid switch mappings - Test that plugin commands execute without crashing on help requests - Test plugin discovery and loading - Test indirect-sign and indirect-verify command execution - Specifically validate the switch mapping conversion that fixed the original bug Also updated: - CoseSignTool.Tests.csproj: Added project reference to CoseSignTool.Abstractions and plugin copy target - MainTests.cs: Filter out expected plugin conflict warnings from stderr assertion
Override GetAdditionalOptionalArguments() to display the payload-location option in the command's help/usage output.
Boolean flags like --allow-untrusted were not working when specified without an explicit value (e.g., '--allow-untrusted' vs '--allow-untrusted true'). This was because Microsoft.Extensions.Configuration.CommandLine requires a value for each switch. When a boolean flag was at the end of the command line without a value, the configuration key didn't exist. Changes: - IPluginCommand.cs: Added BooleanOptions property to interface for plugins to declare which options are boolean flags - PluginCommandBase.cs: Added default empty BooleanOptions, and GetBooleanFlag() helper for proper boolean parsing - CoseSignTool.cs: Added PreprocessBooleanFlags() to insert 'true' for known boolean flags. Uses universal flags (--verbose, etc.) plus plugin-provided BooleanOptions to maintain proper plugin architecture separation - IndirectSignatureCommandBase.cs: Added ValidationBooleanOptions and SigningBooleanOptions arrays - IndirectSignCommand.cs: Override BooleanOptions with SigningBooleanOptions - IndirectVerifyCommand.cs: Override BooleanOptions with ValidationBooleanOptions, use GetBooleanFlag() for allow-untrusted/allow-outdated
a4e9f6b to
e4a3aba
Compare
e4a3aba to
b806d7f
Compare
b806d7f to
ebdbc2a
Compare
elantiguamsft
approved these changes
Jan 28, 2026
NN2000X
approved these changes
Jan 28, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces improved handling for boolean command-line flags in the plugin command infrastructure. It adds explicit support for boolean options that can be specified without a value (e.g.,
--flaginstead of--flag true), both in the core abstractions and in plugin implementations. The changes also include comprehensive tests and adjustments to the command-line argument processing logic to ensure correct behavior for boolean flags.Key changes:
Core Abstractions and Infrastructure
BooleanOptionsproperty to theIPluginCommandinterface and its implementations, allowing each command to specify which options are treated as boolean flags (i.e., can be specified without a value and default totrue). (CoseSignTool.Abstractions/IPluginCommand.cs,CoseSignTool.Abstractions/PluginCommandBase.cs) [1] [2]GetBooleanFlagmethod inPluginCommandBaseto correctly interpret boolean flags from configuration, treating the presence of a flag (with any value except "false") astrue. (CoseSignTool.Abstractions/PluginCommandBase.cs)CoseSignTool.csto automatically insert"true"for recognized boolean flags that are specified without a value, ensuring compatibility with the configuration system. (CoseSignTool/CoseSignTool.cs) [1] [2]Plugin Command Implementations
--enable-scitt,--scitt,--allow-untrusted, and--allow-outdatedare correctly recognized as boolean. (CoseSignTool.IndirectSignature.Plugin/IndirectSignatureCommandBase.cs,CoseSignTool.IndirectSignature.Plugin/IndirectSignCommand.cs,CoseSignTool.IndirectSignature.Plugin/IndirectVerifyCommand.cs) [1] [2] [3]IndirectVerifyCommandto use the newGetBooleanFlagmethod for boolean options, improving correctness and consistency. (CoseSignTool.IndirectSignature.Plugin/IndirectVerifyCommand.cs)Testing and Test Infrastructure
CoseSignTool.Abstractions.Tests/PluginInterfaceTests.cs)CoseSignTool.IndirectSignature.Plugin.Tests/IndirectSignCommandTests.cs,CoseSignTool.IndirectSignature.Plugin.Tests/IndirectVerifyCommandTests.cs) [1] [2]CoseSignTool.Tests/CoseSignTool.Tests.csproj,CoseSignTool.Tests/MainTests.cs) (F733901cL28R28, [1] [2] [3]