Skip to content

Commit

Permalink
make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
DrewDennison committed Jun 12, 2024
1 parent 94b7dab commit 1a868b4
Show file tree
Hide file tree
Showing 18 changed files with 12 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# ruleid: detect-anthropic
# ruleid: detect-generic-ai-anthprop
import anthropic

# ruleid: detect-anthropic
# ruleid: detect-generic-ai-anthprop
client = anthropic.Anthropic(
# ruleid: detect-anthropic
# defaults to os.environ.get("ANTHROPIC_API_KEY")
api_key="my_api_key",
)

message = client.messages.create(
# ruleid: detect-anthropic
# ruleid: detect-generic-ai-anthprop
model="claude-3-opus-20240229",
max_tokens=1024,
messages=[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
rules:
- id: detect-anthropic
- id: detect-generic-ai-anthprop
languages:
- generic
severity: INFO
message: "Possibly found usage of AI: Anthropic"
pattern-either:
- pattern: anthropic
- pattern: Anthropic
- pattern: ANTHROPIC_API_KEY
- pattern: claude
- pattern: CLAUDE_API_KEY
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<html>
<body>
<!-- ... Your HTML and CSS -->
// ruleid: detect-gemini
// ruleid: detect-generic-ai-gem
<!-- Import @google/generative-ai, as shown above. -->
<script type="module">
// ruleid: detect-gemini
// ruleid: detect-generic-ai-gem
import { GoogleGenerativeAI } from "@google/generative-ai";

// Fetch your API_KEY
const API_KEY = "...";

// Access your API key (see "Set up your API key" above)
// ruleid: detect-gemini
// ruleid: detect-generic-ai-gem
const genAI = new GoogleGenerativeAI(API_KEY);

const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash"});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rules:
- id: detect-gemini
- id: detect-generic-ai-gem
languages:
- generic
severity: INFO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# ruleid: detect-openai
OPENAI_API_KEY = "MY_API_KEY"
# ruleid: detect-openai
# ruleid: detect-generic-ai-oai
from openai import OpenAI
# ruleid: detect-openai
# ruleid: detect-generic-ai-oai
client = OpenAI(
# ruleid: detect-openai
# Defaults to os.environ.get("OPENAI_API_KEY")
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
rules:
- id: detect-openai
- id: detect-generic-ai-oai
languages:
- generic
severity: INFO
message: "Possibly found usage of AI: OpenAI"
pattern-either:
- pattern: openai
- pattern: OpenAI
- pattern: OPENAI_API_KEY
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
2 changes: 0 additions & 2 deletions ai/python/detect-anthropic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ rules:
- pattern: Anthropic(...)
- pattern: anthropic.Anthropic(...)
- pattern: $CLIENT.messages.$FUNC(...,model=...,...)
- pattern: ANTHROPIC_API_KEY = ...
- pattern: CLAUDE_API_KEY = ...
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
1 change: 0 additions & 1 deletion ai/python/detect-gemini.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ rules:
message: "Possibly found usage of AI: Gemini"
pattern-either:
- pattern: import google.generativeai
- pattern: GEMINI_API_KEY = ...
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
1 change: 1 addition & 0 deletions ai/python/detect-langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# ruleid: detect-langchain
from langchain_community.llms import Ollama
# ruleid: detect-langchain
llm = Ollama(model="llama2")

# ruleid: detect-langchain
Expand Down
1 change: 0 additions & 1 deletion ai/python/detect-mistral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ rules:
- pattern: import mistralai
- pattern: MistralClient(...)
- pattern: $CLIENT.chat(...,model=...,...)
- pattern: MISTRAL_API_KEY = ...
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
1 change: 0 additions & 1 deletion ai/python/detect-openai.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# ruleid: detect-openai
OPENAI_API_KEY = "MY_API_KEY"
# ruleid: detect-openai
from openai import OpenAI
Expand Down
1 change: 0 additions & 1 deletion ai/python/detect-openai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ rules:
- pattern: from openai import $ANYTHING
- pattern: OpenAI(...)
- pattern: $CLIENT.chat.completions.$FUNC(...)
- pattern: OPENAI_API_KEY = ...
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
2 changes: 0 additions & 2 deletions ai/typescript/detect-anthropic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ rules:
- pattern: import $ANYTHING from "@anthropic-ai";
- pattern: new Anthropic(...)
- pattern: anthropic.messages.$FUNC(...)
- pattern: ANTHROPIC_API_KEY = ...
- pattern: CLAUDE_API_KEY = ...
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
1 change: 0 additions & 1 deletion ai/typescript/detect-gemini.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rules:
- pattern: import $ANYTHING from "@google/generative-ai";
- pattern: new GoogleGenerativeAI(...)
- pattern: $GENAI.getGenerativeModel(...)
- pattern: GEMINI_API_KEY = ...
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
1 change: 0 additions & 1 deletion ai/typescript/detect-mistral.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ruleid: detect-mistral
import MistralClient from '@mistralai/mistralai';

// ruleid: detect-mistral
const apiKey = process.env.MISTRAL_API_KEY;

// ruleid: detect-mistral
Expand Down
2 changes: 0 additions & 2 deletions ai/typescript/detect-mistral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ rules:
- pattern: new MistralClient(...)
- pattern: |-
$CLIENT.chat({model: ...})
- pattern: MISTRAL_API_KEY = ...
- pattern: process.env.MISTRAL_API_KEY
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down
1 change: 0 additions & 1 deletion ai/typescript/detect-openai.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ruleid: detect-openai
import OpenAI from "openai";

// ruleid: detect-openai
OPENAI_API_KEY = "asdf"

// ruleid: detect-openai
Expand Down
1 change: 0 additions & 1 deletion ai/typescript/detect-openai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rules:
- pattern: import $ANYTHING from "openai";
- pattern: new OpenAI(...)
- pattern: $CLIENT.chat.completions.$FUNC(...)
- pattern: OPENAI_API_KEY = ...
metadata:
references:
- http://semgrep.dev/blog/2024/detecting-shadow-ai
Expand Down

0 comments on commit 1a868b4

Please sign in to comment.