Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented May 20, 2025

Resolves #15122

Summary by CodeRabbit

  • New Features
    • Introduced Bitdefender GravityZone integration with actions to get policy details, scan endpoints, move endpoints to groups, and check scan task status.
    • Added instant event sources for new endpoints, incidents, and threats, enabling real-time monitoring and automation.
    • Dynamic dropdowns and property options for easier configuration.
  • Improvements
    • Enhanced app configuration with structured API authentication and dynamic UI selections.
  • Chores
    • Updated package version and dependencies.

@vercel
Copy link

vercel bot commented May 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview May 20, 2025 10:29pm
pipedream-docs ⬜️ Ignored (Inspect) May 20, 2025 10:29pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 20, 2025 10:29pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 20, 2025

Walkthrough

This update introduces a Bitdefender GravityZone integration with dynamic property definitions, authenticated JSON-RPC API methods, and several new actions and instant event sources. It includes actions for scanning endpoints, retrieving policy details, moving endpoints between groups, and monitoring scan tasks. Three webhook-based sources emit events for new threats, new endpoints, and new incidents.

Changes

File(s) Change Summary
components/bitdefender_gravityzone/bitdefender_gravityzone.app.mjs Implements the Bitdefender GravityZone app: dynamic prop definitions for IDs, JSON-RPC API client, and high-level API methods for policies, endpoints, groups, scan tasks, and push events.
components/bitdefender_gravityzone/package.json Updates package version to 0.1.0 and adds dependency on @pipedream/platform.
components/bitdefender_gravityzone/actions/get-policy-details/get-policy-details.mjs
components/bitdefender_gravityzone/actions/get-scan-task-status/get-scan-task-status.mjs
components/bitdefender_gravityzone/actions/move-endpoint-to-group/move-endpoint-to-group.mjs
components/bitdefender_gravityzone/actions/scan-endpoint/scan-endpoint.mjs
Adds actions for getting policy details, scan task status, moving endpoints to groups, and scanning endpoints with validation and API integration.
components/bitdefender_gravityzone/sources/common/base.mjs Adds a reusable base module for webhook sources, handling activation, deactivation, and event processing for push notifications.
components/bitdefender_gravityzone/sources/new-endpoint-added-instant/new-endpoint-added-instant.mjs
components/bitdefender_gravityzone/sources/new-endpoint-added-instant/test-event.mjs
components/bitdefender_gravityzone/sources/new-incident-instant/new-incident-instant.mjs
components/bitdefender_gravityzone/sources/new-incident-instant/test-event.mjs
components/bitdefender_gravityzone/sources/new-threat-detected-instant/new-threat-detected-instant.mjs
components/bitdefender_gravityzone/sources/new-threat-detected-instant/test-event.mjs
Adds three webhook source modules (new endpoint, new incident, new threat) and their test event fixtures for event simulation and deduplication.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant BitdefenderApp
    participant BitdefenderAPI

    User->>Action: Trigger action (e.g., Scan Endpoint)
    Action->>BitdefenderApp: Call API method (e.g., scanEndpoint)
    BitdefenderApp->>BitdefenderAPI: Send JSON-RPC request
    BitdefenderAPI-->>BitdefenderApp: Return response
    BitdefenderApp-->>Action: Return result
    Action-->>User: Output summary and data
Loading
sequenceDiagram
    participant BitdefenderAPI
    participant WebhookSource
    participant PipedreamPlatform

    BitdefenderAPI-->>WebhookSource: Send push event (HTTP POST)
    WebhookSource->>WebhookSource: Process event, generate meta
    WebhookSource->>PipedreamPlatform: Emit event with metadata
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement "scan-endpoint" action to initiate manual antivirus scans with endpoint ID/name and scan type (#15122)
Implement "get-policy-details" action to retrieve all information for a policy by ID (#15122)
Implement "move-endpoint-to-group" action to move endpoint with required IDs (#15122)
Implement "new-threat-detected-instant" source to emit events on threat detection (#15122)
Implement "new-endpoint-added-instant" source to emit events on new endpoint registration (#15122)

Poem

In the warren of code, a new dawn appears,
Bitdefender hops in, allaying our fears.
Endpoints are scanned, and groups rearranged,
With webhooks and actions, the features are ranged.
From threats to new endpoints, alerts now abound—
The rabbit approves, with a soft thumping sound!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/bitdefender_gravityzone/sources/new-endpoint-added-instant/new-endpoint-added-instant.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:163:49)

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between ebb793d and dbda9b6.

📒 Files selected for processing (1)
  • components/bitdefender_gravityzone/sources/new-endpoint-added-instant/new-endpoint-added-instant.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/bitdefender_gravityzone/sources/new-endpoint-added-instant/new-endpoint-added-instant.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: Verify TypeScript components
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@michelle0927 michelle0927 marked this pull request as ready for review May 20, 2025 22:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (11)
components/bitdefender_gravityzone/actions/move-endpoint-to-group/move-endpoint-to-group.mjs (1)

24-39: Consider adding error handling to the API call.

The current implementation doesn't include specific error handling. Consider adding try/catch logic to provide more helpful error messages to users when the API call fails.

async run({ $ }) {
+  try {
    const response = await this.bitdefender.moveEndpointToGroup({
      $,
      data: {
        params: {
          endpointIds: [
            this.endpointId,
          ],
          groupId: this.groupId,
        },
      },
    });

    $.export("$summary", `Successfully moved endpoint ${this.endpointId} to group ${this.groupId}`);
    return response;
+  } catch (error) {
+    $.export("$summary", `Failed to move endpoint: ${error.message}`);
+    throw error;
+  }
}
components/bitdefender_gravityzone/sources/new-incident-instant/test-event.mjs (2)

1-34: Well-structured test event but has a trailing comma issue.

The test event provides a comprehensive representation of a Bitdefender incident, which is excellent for testing. However, there's a formatting issue:

-    "main_action": "no action",
-  }
+    "main_action": "no action"
+  }

The trailing comma at the end of the last property in a JSON object might cause parsing issues in some environments.


26-31: Consider adding comments for ATT&CK technique IDs.

The ATT&CK IDs (like "T1036", "T1059", etc.) represent specific MITRE ATT&CK techniques. Consider adding comments to explain what each technique ID represents for better developer understanding.

   "att_ck_id": [
-      "T1036",
-      "T1059",
-      "T1002",
-      "T1012"
+      "T1036", // Masquerading
+      "T1059", // Command and Scripting Interpreter
+      "T1002", // Data Compression
+      "T1012"  // Query Registry
   ],
components/bitdefender_gravityzone/actions/get-policy-details/get-policy-details.mjs (1)

6-6: Fix documentation link formatting.

There's a missing closing bracket in the documentation link.

- description: "Retrieve details about a specific policy. [See the documentation](https://www.bitdefender.com/business/support/en/77209-135304-getpolicydetails.html)",
+ description: "Retrieve details about a specific policy. [See the documentation](https://www.bitdefender.com/business/support/en/77209-135304-getpolicydetails.html)",
components/bitdefender_gravityzone/sources/new-endpoint-added-instant/new-endpoint-added-instant.mjs (1)

15-17: Fix indentation inconsistency.

The indentation for "endpoint-moved-in" has extra spaces/tabs compared to the rest of the code.

    getEventTypes() {
      return {
-        	"endpoint-moved-in": true,
+        "endpoint-moved-in": true,
      };
    },
components/bitdefender_gravityzone/actions/get-scan-task-status/get-scan-task-status.mjs (1)

6-6: Fix documentation link formatting.

There's a missing closing bracket in the documentation link, which will cause incorrect rendering.

- description: "Get the status of a scan task. [See the documentation(https://www.bitdefender.com/business/support/en/77209-440638-gettaskstatus.html)",
+ description: "Get the status of a scan task. [See the documentation](https://www.bitdefender.com/business/support/en/77209-440638-gettaskstatus.html)",
components/bitdefender_gravityzone/sources/common/base.mjs (1)

52-66: Avoid shadowing the event parameter inside the run loop

The parameter event is re-declared in the for … of loop, which is legal but confusing.
Renaming the outer argument clarifies intent and removes shadowing.

-  async run(event) {
+  async run(reqEvent) {-    const { body } = event;
+    const { body } = reqEvent;-    for (const event of events) {
-      const meta = this.generateMeta(event);
-      this.$emit(event, meta);
+    for (const e of events) {
+      const meta = this.generateMeta(e);
+      this.$emit(e, meta);
     }
components/bitdefender_gravityzone/bitdefender_gravityzone.app.mjs (2)

103-107: Static JSON-RPC id risks collisions

The constant "120000" is sent with every call. Some servers use this field to match responses; duplicates can confuse retry logic and tracing. Consider a per-call random or incremental value.

-          id: "120000",
+          id: Date.now(), // or uuid.v4()

139-162: Pagination helpers drop next-page information

listPolicies, listEndpoints, etc. expose an options() helper that converts result.items into a flat array but never returns hasMore / nextPage flags.
Pipedream’s dynamic dropdowns rely on these flags for infinite scroll.

Consider returning { options, nextPage } where nextPage = page + 1 when the server indicates more pages.

components/bitdefender_gravityzone/actions/scan-endpoint/scan-endpoint.mjs (2)

67-68: Fix typo in scan depth option label.

The label for the permissive scan depth option contains a typo "Permissivearray" instead of "Permissive".

-          label: "Permissivearray",
+          label: "Permissive",
           value: 3,

109-109: Improve the summary message to be more user-friendly.

The current summary uses numeric scan type and endpoint ID, which isn't very readable. Consider using the scan type label instead of the numeric value.

-    $.export("$summary", `Successfully initiated ${this.scanType} scan on endpoint ${this.endpointId}`);
+    const scanTypeLabels = {
+      1: "Quick",
+      2: "Full", 
+      3: "Memory",
+      4: "Custom"
+    };
+    $.export("$summary", `Successfully initiated ${scanTypeLabels[this.scanType]} scan on endpoint ${this.endpointId}`);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between b89161c and ebb793d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • components/bitdefender_gravityzone/actions/get-policy-details/get-policy-details.mjs (1 hunks)
  • components/bitdefender_gravityzone/actions/get-scan-task-status/get-scan-task-status.mjs (1 hunks)
  • components/bitdefender_gravityzone/actions/move-endpoint-to-group/move-endpoint-to-group.mjs (1 hunks)
  • components/bitdefender_gravityzone/actions/scan-endpoint/scan-endpoint.mjs (1 hunks)
  • components/bitdefender_gravityzone/bitdefender_gravityzone.app.mjs (1 hunks)
  • components/bitdefender_gravityzone/package.json (2 hunks)
  • components/bitdefender_gravityzone/sources/common/base.mjs (1 hunks)
  • components/bitdefender_gravityzone/sources/new-endpoint-added-instant/new-endpoint-added-instant.mjs (1 hunks)
  • components/bitdefender_gravityzone/sources/new-endpoint-added-instant/test-event.mjs (1 hunks)
  • components/bitdefender_gravityzone/sources/new-incident-instant/new-incident-instant.mjs (1 hunks)
  • components/bitdefender_gravityzone/sources/new-incident-instant/test-event.mjs (1 hunks)
  • components/bitdefender_gravityzone/sources/new-threat-detected-instant/new-threat-detected-instant.mjs (1 hunks)
  • components/bitdefender_gravityzone/sources/new-threat-detected-instant/test-event.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (13)
components/bitdefender_gravityzone/sources/new-endpoint-added-instant/test-event.mjs (1)

1-11: Test event looks correctly structured and comprehensive.

This test event provides a complete set of mock data for simulating an endpoint addition event. The module value "endpoint-moved-in" correctly identifies the event type.

components/bitdefender_gravityzone/package.json (2)

3-3: Version bump appropriate for new component functionality.

Increasing from 0.0.1 to 0.1.0 follows semantic versioning principles for adding new features.


14-16: Required Pipedream platform dependency added.

Adding the dependency on @pipedream/platform is necessary for accessing core Pipedream functionality.

components/bitdefender_gravityzone/sources/new-threat-detected-instant/test-event.mjs (1)

1-14: Test event has comprehensive threat detection data.

The mock data includes all necessary fields for simulating a threat detection event, with appropriate values for testing. The module value "avc" correctly identifies this as an Anti-Virus Control event.

components/bitdefender_gravityzone/actions/move-endpoint-to-group/move-endpoint-to-group.mjs (1)

3-23: Action definition and props look well-structured.

The action is properly defined with a clear name, description (including documentation link), and appropriate version. The props leverage propDefinitions from the app module, which is good practice.

components/bitdefender_gravityzone/actions/get-policy-details/get-policy-details.mjs (1)

6-6: Documentation link is properly formatted.

The documentation link is correctly formatted with markdown syntax, providing users with direct access to the API reference.

components/bitdefender_gravityzone/sources/new-endpoint-added-instant/new-endpoint-added-instant.mjs (1)

4-12: LGTM - Event source configuration is well-defined.

The source module is properly configured with appropriate key, name, description, and dedupe strategy. The source will emit events when new endpoints are registered in Bitdefender GravityZone.

components/bitdefender_gravityzone/actions/get-scan-task-status/get-scan-task-status.mjs (1)

3-9: Action metadata is well-defined.

The action module is correctly configured with a descriptive name, appropriate versioning, and type definition.

components/bitdefender_gravityzone/sources/common/base.mjs (1)

34-44: Confirm casing of serviceType: "jsonRPC" with API docs

GravityZone’s docs historically show serviceType as "jsonRpc" (lower-case ‘p’).
Using the wrong casing could silently disable webhook delivery.

Please double-check the expected literal in the API reference.

components/bitdefender_gravityzone/bitdefender_gravityzone.app.mjs (1)

101-103: Path concatenation may produce an invalid URL

_baseUrl() already ends with /v1.0/jsonrpc. Appending /policies (etc.) yields
…/jsonrpc/policies, whereas the official endpoint is usually just /jsonrpc.
If the API expects the module name inside the JSON-RPC method string rather than the path, the request will 404.

Please verify with a quick call or the docs.

components/bitdefender_gravityzone/actions/scan-endpoint/scan-endpoint.mjs (3)

80-87: Validation logic looks good!

The validation ensures that scan depth and path are only used for custom scans and that they must be used together. This helps prevent configuration errors.


89-107: Implementation of the scan endpoint call is well structured.

The API call is properly implemented with the necessary parameters. The conditional inclusion of customScanSettings when scanDepth is provided is a clean approach.


1-112: Overall, the component is well-implemented.

This action for scanning endpoints in Bitdefender GravityZone is well-structured with appropriate validation, error handling, and API integration. It follows Pipedream's component patterns and includes good documentation references.

Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

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

LGTM!

@michelle0927 michelle0927 merged commit 6ca6b1f into master May 22, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-15122 branch May 22, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Components] bitdefender_gravityzone

3 participants