Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-sdk/client-detective

Package Overview
Dependencies
Maintainers
0
Versions
410
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/client-detective

AWS SDK for JavaScript Detective Client for Node.js, Browser and React Native

  • 3.696.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38K
increased by54.94%
Maintainers
0
Weekly downloads
 
Created
Source

@aws-sdk/client-detective

Description

AWS SDK for JavaScript Detective Client for Node.js, Browser and React Native.

Detective uses machine learning and purpose-built visualizations to help you to analyze and investigate security issues across your Amazon Web Services (Amazon Web Services) workloads. Detective automatically extracts time-based events such as login attempts, API calls, and network traffic from CloudTrail and Amazon Virtual Private Cloud (Amazon VPC) flow logs. It also extracts findings detected by Amazon GuardDuty.

The Detective API primarily supports the creation and management of behavior graphs. A behavior graph contains the extracted data from a set of member accounts, and is created and managed by an administrator account.

To add a member account to the behavior graph, the administrator account sends an invitation to the account. When the account accepts the invitation, it becomes a member account in the behavior graph.

Detective is also integrated with Organizations. The organization management account designates the Detective administrator account for the organization. That account becomes the administrator account for the organization behavior graph. The Detective administrator account is also the delegated administrator account for Detective in Organizations.

The Detective administrator account can enable any organization account as a member account in the organization behavior graph. The organization accounts do not receive invitations. The Detective administrator account can also invite other accounts to the organization behavior graph.

Every behavior graph is specific to a Region. You can only use the API to manage behavior graphs that belong to the Region that is associated with the currently selected endpoint.

The administrator account for a behavior graph can use the Detective API to do the following:

  • Enable and disable Detective. Enabling Detective creates a new behavior graph.

  • View the list of member accounts in a behavior graph.

  • Add member accounts to a behavior graph.

  • Remove member accounts from a behavior graph.

  • Apply tags to a behavior graph.

The organization management account can use the Detective API to select the delegated administrator for Detective.

The Detective administrator account for an organization can use the Detective API to do the following:

  • Perform all of the functions of an administrator account.

  • Determine whether to automatically enable new organization accounts as member accounts in the organization behavior graph.

An invited member account can use the Detective API to do the following:

  • View the list of behavior graphs that they are invited to.

  • Accept an invitation to contribute to a behavior graph.

  • Decline an invitation to contribute to a behavior graph.

  • Remove their account from a behavior graph.

All API actions are logged as CloudTrail events. See Logging Detective API Calls with CloudTrail.

We replaced the term "master account" with the term "administrator account". An administrator account is used to centrally manage multiple accounts. In the case of Detective, the administrator account manages the accounts in their behavior graph.

Installing

To install this package, simply type add or install @aws-sdk/client-detective using your favorite package manager:

  • npm install @aws-sdk/client-detective
  • yarn add @aws-sdk/client-detective
  • pnpm add @aws-sdk/client-detective

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the DetectiveClient and the commands you need, for example ListGraphsCommand:

// ES5 example
const { DetectiveClient, ListGraphsCommand } = require("@aws-sdk/client-detective");
// ES6+ example
import { DetectiveClient, ListGraphsCommand } from "@aws-sdk/client-detective";

Usage

To send a request, you:

  • Initiate client with configuration (e.g. credentials, region).
  • Initiate command with input parameters.
  • Call send operation on client with command object as input.
  • If you are using a custom http handler, you may call destroy() to close open connections.
// a client can be shared by different commands.
const client = new DetectiveClient({ region: "REGION" });

const params = {
  /** input parameters */
};
const command = new ListGraphsCommand(params);
Async/await

We recommend using await operator to wait for the promise returned by send operation as follows:

// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Async-await is clean, concise, intuitive, easy to debug and has better error handling as compared to using Promise chains or callbacks.

Promises

You can also use Promise chaining to execute send operation.

client.send(command).then(
  (data) => {
    // process data.
  },
  (error) => {
    // error handling.
  }
);

Promises can also be called using .catch() and .finally() as follows:

client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });
Callbacks

We do not recommend using callbacks because of callback hell, but they are supported by the send operation.

// callbacks.
client.send(command, (err, data) => {
  // process err and data.
});
v2 compatible style

The client can also send requests using v2 compatible style. However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post on modular packages in AWS SDK for JavaScript

import * as AWS from "@aws-sdk/client-detective";
const client = new AWS.Detective({ region: "REGION" });

// async/await.
try {
  const data = await client.listGraphs(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .listGraphs(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks.
client.listGraphs(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

Getting Help

Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-detective package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

AcceptInvitation

Command API Reference / Input / Output

BatchGetGraphMemberDatasources

Command API Reference / Input / Output

BatchGetMembershipDatasources

Command API Reference / Input / Output

CreateGraph

Command API Reference / Input / Output

CreateMembers

Command API Reference / Input / Output

DeleteGraph

Command API Reference / Input / Output

DeleteMembers

Command API Reference / Input / Output

DescribeOrganizationConfiguration

Command API Reference / Input / Output

DisableOrganizationAdminAccount

Command API Reference / Input / Output

DisassociateMembership

Command API Reference / Input / Output

EnableOrganizationAdminAccount

Command API Reference / Input / Output

GetInvestigation

Command API Reference / Input / Output

GetMembers

Command API Reference / Input / Output

ListDatasourcePackages

Command API Reference / Input / Output

ListGraphs

Command API Reference / Input / Output

ListIndicators

Command API Reference / Input / Output

ListInvestigations

Command API Reference / Input / Output

ListInvitations

Command API Reference / Input / Output

ListMembers

Command API Reference / Input / Output

ListOrganizationAdminAccounts

Command API Reference / Input / Output

ListTagsForResource

Command API Reference / Input / Output

RejectInvitation

Command API Reference / Input / Output

StartInvestigation

Command API Reference / Input / Output

StartMonitoringMember

Command API Reference / Input / Output

TagResource

Command API Reference / Input / Output

UntagResource

Command API Reference / Input / Output

UpdateDatasourcePackages

Command API Reference / Input / Output

UpdateInvestigationState

Command API Reference / Input / Output

UpdateOrganizationConfiguration

Command API Reference / Input / Output

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc