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/

../_images/image_2.jpg
  • The results will look something like this:

../_images/chatgpt_1.png
  • 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”:

../_images/image_4.jpg
  • Next, open your ScanCode.io URL and click on the “New Project” button.

../_images/image_3.jpg
  • Click “Drop files over here (or click)” and upload the saved “foo.js” file.

../_images/image_5.jpg
  • Then select the initial “scan_codebase” pipeline and click the “Create” button:

../_images/image_7.jpg
  • Click “Add pipeline” button.

../_images/image_8.jpg
  • Then select the “fingerprint_codebase” and cliem the “Add pipeline” button.

../_images/image_9.jpg
  • Repeat with the “match_to_matchcode” pipeline:

../_images/image_12.jpg
  • When the scan is done, click the “Resources” link to see the match results

../_images/image_14.jpg
  • 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/

../_images/image_15.jpg
  • Click on “pkg:github/isaacs/inherits@v2.0.3” package link.

../_images/image_16.jpg
  • From there click on the “Resources” tab:

../_images/image_17.jpg
  • Click the “foo.js” link to see the file details.

../_images/image_18.jpg
  • Click on the “Viewer” tab to see the file content.

../_images/image_19.jpg
  • Click “Matched Snippets” sub-tab of the viewer to see the highlighted matched code:

../_images/image_20.jpg
  • The AI-generated code is highlighted as matched code below:

../_images/image_21.png
../_images/image_22.png