Skip to content

Add --payload-location option for IndirectSignature#158

Merged
elantiguamsft merged 1 commit intomainfrom
users/jstatia/update_indirect_signature
Jan 28, 2026
Merged

Add --payload-location option for IndirectSignature#158
elantiguamsft merged 1 commit intomainfrom
users/jstatia/update_indirect_signature

Conversation

@JeromySt
Copy link
Member

  • Add payloadLocation parameter to IndirectSignatureFactory methods
  • Add --payload-location CLI option to IndirectSignCommand
  • Wire payload location through CoseHashEnvelopeHeaderExtender (label 260 per RFC 9054)
  • Add tests for payload location in both factory and plugin tests
  • Update IndirectSignaturePlugin.md documentation
  • Update SCITTCompliance.md with Payload Location section

closes #157

- Add payloadLocation parameter to IndirectSignatureFactory methods
- Add --payload-location CLI option to IndirectSignCommand
- Wire payload location through CoseHashEnvelopeHeaderExtender (label 260 per RFC 9054)
- Add tests for payload location in both factory and plugin tests
- Update IndirectSignaturePlugin.md documentation
- Update SCITTCompliance.md with Payload Location section
IDictionary<string, string> options = command.Options;

// Assert
Assert.IsTrue(options.ContainsKey("payload-location"), "Options should contain payload-location");

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note test

Inefficient use of 'ContainsKey' and
indexer
.

Copilot Autofix

AI about 2 months ago

In general, to fix this pattern, replace dictionary.ContainsKey(key) followed by dictionary[key] with a single dictionary.TryGetValue(key, out var value) and use value for subsequent checks. This consolidates two lookups into one and avoids a potential KeyNotFoundException.

In this specific test, we should replace the assertion that checks for the key with a TryGetValue call that also retrieves the description. Then we can assert that the retrieved description contains "URI". Concretely, in IndirectSignCommand_Options_ShouldContainPayloadLocationOption in CoseSignTool.IndirectSignature.Plugin.Tests/IndirectSignCommandTests.cs, replace the two lines:

Assert.IsTrue(options.ContainsKey("payload-location"), "Options should contain payload-location");
Assert.IsTrue(options["payload-location"].Contains("URI"), "payload-location description should mention URI");

with code that first asserts TryGetValue succeeds, captures the option description into a local variable, and then checks that this string contains "URI". No new imports or helper methods are needed; we only use existing IDictionary<string,string> APIs and MSTest assertions.

Suggested changeset 1
CoseSignTool.IndirectSignature.Plugin.Tests/IndirectSignCommandTests.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/CoseSignTool.IndirectSignature.Plugin.Tests/IndirectSignCommandTests.cs b/CoseSignTool.IndirectSignature.Plugin.Tests/IndirectSignCommandTests.cs
--- a/CoseSignTool.IndirectSignature.Plugin.Tests/IndirectSignCommandTests.cs
+++ b/CoseSignTool.IndirectSignature.Plugin.Tests/IndirectSignCommandTests.cs
@@ -1030,8 +1030,8 @@
         IDictionary<string, string> options = command.Options;
 
         // Assert
-        Assert.IsTrue(options.ContainsKey("payload-location"), "Options should contain payload-location");
-        Assert.IsTrue(options["payload-location"].Contains("URI"), "payload-location description should mention URI");
+        Assert.IsTrue(options.TryGetValue("payload-location", out string payloadLocationDescription), "Options should contain payload-location");
+        Assert.IsTrue(payloadLocationDescription.Contains("URI"), "payload-location description should mention URI");
     }
 
     [TestMethod]
EOF
@@ -1030,8 +1030,8 @@
IDictionary<string, string> options = command.Options;

// Assert
Assert.IsTrue(options.ContainsKey("payload-location"), "Options should contain payload-location");
Assert.IsTrue(options["payload-location"].Contains("URI"), "payload-location description should mention URI");
Assert.IsTrue(options.TryGetValue("payload-location", out string payloadLocationDescription), "Options should contain payload-location");
Assert.IsTrue(payloadLocationDescription.Contains("URI"), "payload-location description should mention URI");
}

[TestMethod]
Copilot is powered by AI and may make mistakes. Always verify output.
@elantiguamsft elantiguamsft merged commit 602c03c into main Jan 28, 2026
11 checks passed
@elantiguamsft elantiguamsft deleted the users/jstatia/update_indirect_signature branch January 28, 2026 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support setting payload_location(260) with indirect-sign/COSE Hash Envelope

4 participants