Step-by-step: Find AI-generated code with AboutCode
In this tutorial, we first generate code using ChatGPT, then scan the generated code in ScanCode using the MatchCode pipeline.
Visit chatgpt.com
Enter this prompt to generate code:
Write JS code that is similar to https://github.com/isaacs/inherits/
|
The results will look something like this:
|
Click “Copy” button to copy the generated code then paste this in a text editor to save the generated code to a file named “foo.js”:
|
Next, open your ScanCode.io URL and click on the “New Project” button.
|
Click “Drop files over here (or click)” and upload the saved “foo.js” file.
|
Then select the initial “scan_codebase” pipeline and click the “Create” button:
|
Click “Add pipeline” button.
|
Then select the “fingerprint_codebase” and cliem the “Add pipeline” button.
|
Repeat with the “match_to_matchcode” pipeline:
|
When the scan is done, click the “Resources” link to see the match results
|
You can see the file was matched to the “pkg:github/isaacs/inherits@v2.0.3” PURL. This is for this package: https://github.com/isaacs/inherits/
|
Click on “pkg:github/isaacs/inherits@v2.0.3” package link.
|
From there click on the “Resources” tab:
|
Click the “foo.js” link to see the file details.
|
Click on the “Viewer” tab to see the file content.
|
Click “Matched Snippets” sub-tab of the viewer to see the highlighted matched code:
|
The AI-generated code is highlighted as matched code below:
|
The matched original code is also highlighted for reference: https://github.com/isaacs/inherits/blob/v2.0.3/inherits_browser.js
|