Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt Security's extension integration #784

Closed
wants to merge 17 commits into from

Conversation

guy-ps
Copy link

@guy-ps guy-ps commented Mar 7, 2024

By submitting a PR to this repository, you agree to the terms within the Checkmarx Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

In this PR, I added the functionality that will allow this vscode extension and Prompt Security's functionally in the browser extension communicate.

The process:

  • The vscode extension creates a local express server that awaits API calls from the browser extension
  • Listens to text selection events and saves the last 25
  • The browser extension calls the local server if code is sent as part of the prompt
  • If the code matches a selected section the vscode extension returns the code and the file
  • The browser extension shows a pop up message

Things left to do:

  • Create a checkbox to activate Prompt Security's part of the extension
  • Consume the local server's port number dynamically

References

Include supporting link to GitHub Issue/PR number

Testing

The Prompt security vscode extension was tested in house

I've been having issues with the as-cli-javascript-wrapper package, so I wasn't able to test it post integration.

Checklist

  • I have added documentation for new/changed functionality in this PR (if applicable).
  • [?] All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used

guy-ps added 5 commits March 6, 2024 18:18
Because it threw an error for the"any type in lastSelectedCodeSections declaration, I made an interface
One class for now, maybe we'll split it
Followup on Lior's comments
@pedrompflopes pedrompflopes requested review from a team, sshay77 and helderfvieira and removed request for a team March 7, 2024 14:06
src/extension.ts Outdated Show resolved Hide resolved
@tiagobcx tiagobcx self-requested a review March 7, 2024 15:32
guy-ps added 6 commits March 7, 2024 18:12
Added a private registerPromptListener method that takes in the port number as input, and builds the local server
Relocated most of the functionality into the class, and left the registerPromptListener alongside the constructor and the deactivation in the extension.ts
@guy-ps guy-ps requested a review from OrShamirCM March 12, 2024 17:40
Copy link
Contributor

@OrShamirCM OrShamirCM left a comment

Choose a reason for hiding this comment

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

Can you add unit test please?

guy-ps and others added 2 commits March 20, 2024 13:40
Added try/catch for the registerPromptListener function
Added checks for null in lines 53 and 83
Refactored the code to have some functions fit unit testing architecture , and wrote some unit tests
@guy-ps guy-ps requested a review from OrShamirCM March 20, 2024 14:42
Added try/catch to every method
@guy-ps guy-ps requested a review from OrShamirCM March 21, 2024 14:44
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.

4 participants