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

feat: add ChatGPT #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions routes/chatbot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check failure on line 1 in routes/chatbot.ts

View workflow job for this annotation

GitHub Actions / e2e (ubuntu-latest, chrome)

'from' expected.

Check failure on line 1 in routes/chatbot.ts

View workflow job for this annotation

GitHub Actions / e2e (ubuntu-latest, chrome)

'from' expected.

Check failure on line 1 in routes/chatbot.ts

View workflow job for this annotation

GitHub Actions / smoke-test

'from' expected.

Check failure on line 1 in routes/chatbot.ts

View workflow job for this annotation

GitHub Actions / smoke-test

'from' expected.

Check failure on line 1 in routes/chatbot.ts

View workflow job for this annotation

GitHub Actions / e2e (macos-latest, chrome)

'from' expected.

Check failure on line 1 in routes/chatbot.ts

View workflow job for this annotation

GitHub Actions / e2e (macos-latest, chrome)

'from' expected.

Check failure on line 1 in routes/chatbot.ts

View workflow job for this annotation

GitHub Actions / coding-challenge-rsn

'from' expected.

Check failure on line 1 in routes/chatbot.ts

View workflow job for this annotation

GitHub Actions / coding-challenge-rsn

'from' expected.
* Copyright (c) 2014-2023 Bjoern Kimminich & the OWASP Juice Shop contributors.
* SPDX-License-Identifier: MIT
*/
Expand All @@ -18,6 +18,7 @@
import validateChatBot from '../lib/startup/validateChatBot'
import * as security from '../lib/insecurity'
import * as botUtils from '../lib/botUtils'
import { OpenAIApi, Configuration } = require("openai")

const challenges = require('../data/datacache').challenges

Expand Down Expand Up @@ -48,6 +49,23 @@

void initialize()

async function processQueryWithChatGPT (user: User, req: Request, res: Response, next: NextFunction) {
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
})
const openai = new OpenAIApi(configuration)

const completion = await openai.createCompletion({
model: "text-davinci-003",
prompt: `Hello world ${user.email}`,
})
Comment on lines +58 to +61
Copy link
Author

Choose a reason for hiding this comment

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

🚫 [Bearer] <javascript_third_parties_openai> reported by reviewdog 🐶

Sensitive data sent to OpenAI detected.

Description

Leaking sensitive data to third-party is a common cause of data leaks and can lead to data breaches. This rule looks for instances of sensitive data sent to OpenAI.

Remediations

When using a third-party, ensure all sensitive data is removed.


res.status(200).json({
action: 'response',
body: completion.data.choices[0].text
})
}

async function processQuery (user: User, req: Request, res: Response, next: NextFunction) {
if (!bot) {
res.status(503).send()
Expand Down
Loading