Skip to content
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
Expand Up @@ -18,6 +18,7 @@ import { Bot } from 'juicy-chat-bot'
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 @@ export async function initialize () {

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