-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add webhook to block users in Baleen from Datadog
- Loading branch information
1 parent
d46831c
commit 68d8db4
Showing
8 changed files
with
163 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Boom from '@hapi/boom'; | ||
|
||
import { config } from '../../config.js'; | ||
import * as cdnServices from '../services/cdn.js'; | ||
|
||
const securities = { | ||
async blockAccessOnBaleen(request) { | ||
console.log(request.headers.authorization); | ||
console.log(config.datadog.token); | ||
|
||
if (request.headers.authorization !== config.datadog.token) { | ||
throw Boom.unauthorized('Token is missing or is incorrect'); | ||
} | ||
|
||
const { ip, ja3, eventId } = request.payload; | ||
try { | ||
return await cdnServices.blockAccess({ ip, ja3, eventId }); | ||
} catch (error) { | ||
if (error instanceof cdnServices.NamespaceNotFoundError) { | ||
return Boom.badRequest(); | ||
} | ||
return error; | ||
} | ||
}, | ||
}; | ||
|
||
export default securities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import securityController from '../controllers/security.js'; | ||
import Joi from 'joi'; | ||
|
||
const securities = [ | ||
{ | ||
method: 'POST', | ||
path: '/security/block-access-on-baleen-from-datadog', | ||
handler: securityController.blockAccessOnBaleen, | ||
config: { | ||
validate: { | ||
payload: Joi.object({ | ||
eventId: Joi.string().required(), | ||
ip: Joi.string(), | ||
ja3: Joi.string() | ||
}).or('ip', 'ja3'), | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
export default securities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters