Skip to content

Conversation

HybridProgrammer
Copy link

  • Add SignatureAlgorithm enum with SHA-256 as default and SHA-1 for legacy support
  • Switch default from SHA1 to SHA-256
  • Extend GHWebhookSignature class to support SHA-256 HMAC computation
  • Update HookSecretConfig to include configurable signature algorithm
  • Add UI option to allow users to switch back to legacy SHA1 option
  • Modify RequirePostWithGHHookPayload.Processor to use configured algorithm
  • Add comprehensive unit tests for SHA-256 functionality
  • Maintain backwards compatibility with existing SHA-1 configurations
  • Log deprecation warnings when SHA-1 is used

This implements GitHub's recommended SHA-256 HMAC signature validation while maintaining backwards compatibility through configuration. SHA-256 becomes the default for enhanced security.

Resolves: JENKINS-73851

Testing done

./mvnw -s /tmp/maven-settings.xml test  -Dtest=HookSecretConfigSHA256Test
...
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.jenkinsci.plugins.github.config.HookSecretConfigSHA256Test
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 s -- in org.jenkinsci.plugins.github.config.HookSecretConfigSHA256Test
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

Jason Heithoff and others added 4 commits August 25, 2025 16:04
- Add SignatureAlgorithm enum with SHA-256 as default and SHA-1 for legacy support
- Extend GHWebhookSignature class to support SHA-256 HMAC computation
- Update HookSecretConfig to include configurable signature algorithm
- Modify RequirePostWithGHHookPayload.Processor to use configured algorithm
- Add comprehensive unit tests for SHA-256 functionality
- Maintain backwards compatibility with existing SHA-1 configurations
- Log deprecation warnings when SHA-1 is used

This implements GitHub's recommended SHA-256 HMAC signature validation
while maintaining backwards compatibility through configuration.
SHA-256 becomes the default for enhanced security.

Resolves: JENKINS-73851

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add doFillSignatureAlgorithmItems() method to provide dropdown options
- Create signature algorithm selection dropdown in Jenkins configuration UI
- Add help documentation for signature algorithm selection
- Update HookSecretConfig constructor to parse algorithm from UI string input
- Add parseSignatureAlgorithm() method with case-insensitive parsing
- Update tests to work with new string-based constructor
- Add comprehensive test cases for algorithm parsing edge cases

Users can now choose between SHA-256 (Recommended) and SHA-1 (Legacy)
signature algorithms through the Jenkins UI in the GitHub plugin
configuration section.

The dropdown properly displays both options with SHA-256 set as default
for enhanced security, while SHA-1 remains available for legacy compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove trailing whitespace from all modified files
- Fix line length violations by properly wrapping long lines
- Fix operator wrap issues by placing operators on new lines
- Maintain consistent code formatting throughout

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove IDE-specific configuration file from version control
- Add .vscode/ directory to .gitignore to prevent future tracking
- Keep IDE configurations local to individual developer environments

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@HybridProgrammer HybridProgrammer requested a review from a team as a code owner August 25, 2025 23:48
@HybridProgrammer
Copy link
Author

Request method:	POST
Request URI:	http://localhost:50084/jenkins/github-webhook/
Proxy:			<none>
Request params:	<none>
Query params:	<none>
Form params:	<none>
Path params:	<none>
Headers:		X-GitHub-Event=push
				X-Hub-Signature=sha1=355e155fc3d10c4e5f2c6086a01281d2e947d932
				Accept=*/*
				Content-Type=application/json

Maybe we can discuss about adding SHA-256 headers to validation tests. This is something github adds by default.

…re algorithm

- Add jenkins.github.webhook.signature.default system property
- Allows overriding default from SHA-256 to SHA-1 for CI compatibility
- Maintains SHA-256 as secure default when no property is set
- Dynamic evaluation prevents static initialization issues
- Added comprehensive test coverage and documentation

Usage:
- Default: SHA-256 (secure)
- CI override: -Djenkins.github.webhook.signature.default=SHA1
- Invalid values fallback to SHA-256

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@HybridProgrammer HybridProgrammer changed the title Add SHA-256 HMAC webhook signature validation JENKINS-73851 Add SHA-256 HMAC webhook signature validation Aug 26, 2025
@HybridProgrammer HybridProgrammer changed the title JENKINS-73851 Add SHA-256 HMAC webhook signature validation [JENKINS-73851] Add SHA-256 HMAC webhook signature validation Aug 26, 2025
@KostyaSha
Copy link
Member

some test failure..

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.

2 participants