Skip to content

feat(javascript): Add diffiehellman - #8

Open
jrepucci-rh wants to merge 6 commits into
mainfrom
add_diffiehellman
Open

jrepucci-rh wants to merge 6 commits into
mainfrom
add_diffiehellman

Conversation

@jrepucci-rh

@jrepucci-rh jrepucci-rh commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Added Node.js Crypto rules for Diffie-Hellman key exchanges.

AI Generated by: Claude (using Opus 5)

Type of change

  • New rule(s)
  • New / updated test fixtures
  • Bug fix (false positive / false negative)
  • Test framework or tooling
  • Documentation

Checklist

  • New / changed rules have matching test fixtures
  • make test passes locally
  • Rule files validate with opengrep --validate
  • Commits follow Conventional Commits
  • No private or internal data is included in this change

Notes for reviewers

Header comments in these files were written by AI and likely inaccurate. View them as notes for the reviewer that may point to blind spots in the patterns. Take them with a grain of salt.

@jrepucci-rh jrepucci-rh changed the title Add diffiehellman feat(javascript): Add diffiehellman Sep 25, 2026
@jrepucci-rh
jrepucci-rh marked this pull request as ready for review September 25, 2026 19:00

@isasmendiagus isasmendiagus left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good. One fix before merging, see the inline comment.

Also, the title says "diffiehellman" but finite-field DH is not covered. Could you rename it to "ECDH, X25519 and X448"? DH can be a follow-up.

- pattern: |
$ECDH = <... $C.$MAKE(...) ...>
...
$ECDH2 = <... $ECDH ...>

@isasmendiagus isasmendiagus Oct 13, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches any assignment that mentions $ECDH, not only a copy of it. That's what causes the { ec, ff } false positive from #7.

Suggestion: replace it with two patterns, $ECDH2 = $ECDH and $ECDH2 = $ECDH.$M(...). I tested it: the chained case still works, your four false positives go away, and the existing fixtures pass. Same on lines 87, 108 and 118.

Please also add the alias case and one negative to the fixture.

@jrepucci-rh

Copy link
Copy Markdown
Collaborator Author

Hey @isasmendiagus could you point me to the functions/objects that invoke finite field Diffiehellman? I thought I was covering every major Diffiehellman fucntion in the crypto library.

@jrepucci-rh

Copy link
Copy Markdown
Collaborator Author

@isasmendiagus Comments addressed. Lots of new test files, as in order to catch these new aliases I need a new file per test. Let me know if anything more is needed!

@isasmendiagus isasmendiagus left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the extra fixtures.

On your question: I read "diffiehellman" as the finite-field algorithm (createDiffieHellman(), getDiffieHellman(), and diffieHellman() over 'dh' keys), which your rules leave out on purpose. You meant the crypto.diffieHellman() function, which is covered. So nothing is missing, just the title could say "ECDH, X25519 and X448". Not blocking.

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