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

Add Codex vuln detector #1498

Merged
merged 4 commits into from
Dec 7, 2022
Merged

Add Codex vuln detector #1498

merged 4 commits into from
Dec 7, 2022

Conversation

montyly
Copy link
Member

@montyly montyly commented Dec 6, 2022

The detector requires:

  • The user set the flag --codex (meaning that codex is not ran by default)
  • openai must be installed, and OPENAI_API_KEY set

The detector works at the contract level, and send the whole contract body to codex

The detector requires:
- The user to use the flag `--codex` (meaning that codex is not ran by default)
- `openai` must be installed, and `OPENAI_API_KEY` set

The detector works at the contract level, and send the whole contract body to codex
@lgtm-com
Copy link

lgtm-com bot commented Dec 6, 2022

This pull request introduces 1 alert when merging c02231f into 0dc2a49 - view on LGTM.com

new alerts:

  • 1 for Unused import

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

@lgtm-com
Copy link

lgtm-com bot commented Dec 6, 2022

This pull request introduces 1 alert when merging 5763c74 into 0dc2a49 - view on LGTM.com

new alerts:

  • 1 for Unused import

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

openai.api_key = api_key

for contract in self.compilation_unit.contracts:
prompt = "Is there a vulnerability in this solidity contracts?\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why, but no matter what contract I used, I kept getting "No vulnerabilities found". When I changed the prompt up to something like "Analyze this contract and report the vulns" It started working for me.

end = src_mapping.start + src_mapping.length
prompt += content[start:end]
answer = openai.Completion.create( # type: ignore
model="text-davinci-003", prompt=prompt, temperature=0, max_tokens=200
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been playing around with these numbers temperature and max_tokens but haven't noticed a big difference. I think it would be nice if these were all parameterized. I'll be submitting a pr based on this branch that does that.

"--codex",
help="Enable codex (require an OpenAI API Key)",
action="store_true",
default=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add this key to the defaults_flag_in_config dict?

Refactor functions/codex
Minor improvements
@lgtm-com
Copy link

lgtm-com bot commented Dec 7, 2022

This pull request introduces 1 alert when merging f62433b into 0dc2a49 - view on LGTM.com

new alerts:

  • 1 for Unused import

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

@montyly montyly merged commit adb3eb1 into dev Dec 7, 2022
@montyly montyly deleted the dev-codex branch December 7, 2022 12:35
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