Skip to content

Conversation

@anatolyshipitz
Copy link
Collaborator

Add QuickBooks Online OAuth2 configuration parameters to support the QBO integration for weekly financial reports.

…ters

- Added new OAuth2 configuration parameters to `qbo.ts`, including `clientId`, `clientSecret`, `companyId`, `refreshToken`, and `tokenEndpoint`.
- Updated the Zod schema validation to require the new parameters, ensuring proper validation of environment variables.

These changes improve the application's integration with the QBO API by providing necessary authentication details and enhancing configuration management.
…ters

- Added QuickBooks Online (QBO) configuration parameters to the `.env.example` file, including `QBO_API_URL`, `QBO_CLIENT_ID`, `QBO_CLIENT_SECRET`, `QBO_COMPANY_ID`, `QBO_REFRESH_TOKEN`, and `QBO_TOKEN_ENDPOINT`.
- This update enhances the application's environment setup for QBO integration by providing necessary configuration details for OAuth2 authentication.

These changes improve the clarity and usability of the environment configuration for developers working with the QBO API.
@anatolyshipitz anatolyshipitz requested a review from killev as a code owner July 29, 2025 10:15
@coderabbitai
Copy link

coderabbitai bot commented Jul 29, 2025

📝 Walkthrough

"""

Walkthrough

The changes introduce OAuth2-related environment variables for QuickBooks Online (QBO) integration in the .env.example and .env.test files and extend the QBO configuration and validation schema in qbo.ts to support these new parameters. No existing variables or configurations were removed or altered.

Changes

Cohort / File(s) Change Summary
Environment Variable Example Update
.env.example
Added a new section for QBO OAuth2 configuration variables, including API URL, client ID, client secret, company ID, refresh token, and token endpoint.
Test Environment Variable Update
workers/main/.env.test
Added OAuth2-related QBO environment variables: client ID, client secret, company ID, refresh token, and token endpoint for testing purposes.
QBO Config and Schema Extension
workers/main/src/configs/qbo.ts
Extended qboConfig and qboSchema to support OAuth2 parameters: client ID, client secret, refresh token, company ID, optional token endpoint, and made bearer token optional.

Sequence Diagram(s)

sequenceDiagram
    participant EnvFile as .env.example / .env.test
    participant Config as qboConfig/qboSchema
    participant App as Application

    EnvFile->>Config: Provides OAuth2 env vars (clientId, clientSecret, etc.)
    Config->>App: Supplies validated QBO configuration (OAuth2 or bearer token)
    App->>QBO API: Authenticates using OAuth2 credentials or bearer token
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • killev
    """

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/65031_add_oauth2_parameters

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 generate unit tests to generate unit tests for 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.

@anatolyshipitz anatolyshipitz enabled auto-merge (squash) July 29, 2025 10:16
@github-actions
Copy link

github-actions bot commented Jul 29, 2025

🔍 Vulnerabilities of temporal-test:latest

📦 Image Reference temporal-test:latest
digestsha256:da30eca7154c7c4cb2616e31f7411021ea9146d5b15c68adf2a57df4c52b164c
vulnerabilitiescritical: 2 high: 7 medium: 0 low: 0
platformlinux/amd64
size218 MB
packages358
📦 Base Image alpine:3
also known as
  • 3.21
  • 3.21.3
  • latest
digestsha256:1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474
vulnerabilitiescritical: 0 high: 0 medium: 0 low: 0
critical: 1 high: 0 medium: 0 low: 0 stdlib 1.23.6 (golang)

pkg:golang/stdlib@1.23.6

critical : CVE--2025--22871

Affected range<1.23.8
Fixed version1.23.8
EPSS Score0.023%
EPSS Percentile4th percentile
Description

The net/http package improperly accepts a bare LF as a line terminator in chunked data chunk-size lines. This can permit request smuggling if a net/http server is used in conjunction with a server that incorrectly accepts a bare LF as part of a chunk-ext.

critical: 1 high: 0 medium: 0 low: 0 stdlib 1.23.2 (golang)

pkg:golang/stdlib@1.23.2

critical : CVE--2025--22871

Affected range<1.23.8
Fixed version1.23.8
EPSS Score0.023%
EPSS Percentile4th percentile
Description

The net/http package improperly accepts a bare LF as a line terminator in chunked data chunk-size lines. This can permit request smuggling if a net/http server is used in conjunction with a server that incorrectly accepts a bare LF as part of a chunk-ext.

critical: 0 high: 1 medium: 0 low: 0 golang.org/x/crypto 0.32.0 (golang)

pkg:golang/golang.org/x/crypto@0.32.0

high : CVE--2025--22869

Affected range<0.35.0
Fixed version0.35.0
EPSS Score0.127%
EPSS Percentile33rd percentile
Description

SSH servers which implement file transfer protocols are vulnerable to a denial of service attack from clients which complete the key exchange slowly, or not at all, causing pending content to be read into memory, but never transmitted.

critical: 0 high: 1 medium: 0 low: 0 golang.org/x/oauth2 0.26.0 (golang)

pkg:golang/golang.org/x/oauth2@0.26.0

high 7.5: CVE--2025--22868 Improper Validation of Syntactic Correctness of Input

Affected range<0.27.0
Fixed version0.27.0
CVSS Score7.5
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Score0.065%
EPSS Percentile21st percentile
Description

An attacker can pass a malicious malformed token which causes unexpected memory to be consumed during parsing.

critical: 0 high: 1 medium: 0 low: 0 github.com/golang-jwt/jwt/v4 4.5.1 (golang)

pkg:golang/github.com/golang-jwt/jwt@4.5.1#v4

high 8.7: CVE--2025--30204 Asymmetric Resource Consumption (Amplification)

Affected range<4.5.2
Fixed version4.5.2
CVSS Score8.7
CVSS VectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
EPSS Score0.033%
EPSS Percentile8th percentile
Description

Summary

Function parse.ParseUnverified currently splits (via a call to strings.Split) its argument (which is untrusted data) on periods.

As a result, in the face of a malicious request whose Authorization header consists of Bearer followed by many period characters, a call to that function incurs allocations to the tune of O(n) bytes (where n stands for the length of the function's argument), with a constant factor of about 16. Relevant weakness: CWE-405: Asymmetric Resource Consumption (Amplification)

Details

See parse.ParseUnverified

Impact

Excessive memory allocation

critical: 0 high: 1 medium: 0 low: 0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc 0.36.4 (golang)

pkg:golang/go.opentelemetry.io/contrib/instrumentation@0.36.4#google.golang.org/grpc/otelgrpc

high 7.5: CVE--2023--47108 Allocation of Resources Without Limits or Throttling

Affected range<0.46.0
Fixed version0.46.0
CVSS Score7.5
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Score2.744%
EPSS Percentile85th percentile
Description

Summary

The grpc Unary Server Interceptor opentelemetry-go-contrib/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go

// UnaryServerInterceptor returns a grpc.UnaryServerInterceptor suitable
// for use in a grpc.NewServer call.
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor {

out of the box adds labels

  • net.peer.sock.addr
  • net.peer.sock.port

that have unbound cardinality. It leads to the server's potential memory exhaustion when many malicious requests are sent.

Details

An attacker can easily flood the peer address and port for requests.

PoC

Apply the attached patch to the example and run the client multiple times. Observe how each request will create a unique histogram and how the memory consumption increases during it.

Impact

In order to be affected, the program has to configure a metrics pipeline, use UnaryServerInterceptor, and does not filter any client IP address and ports via middleware or proxies, etc.

Others

It is similar to already reported vulnerabilities.

Workaround for affected versions

As a workaround to stop being affected, a view removing the attributes can be used.

The other possibility is to disable grpc metrics instrumentation by passing otelgrpc.WithMeterProvider option with noop.NewMeterProvider.

Solution provided by upgrading

In PR #4322, to be released with v0.46.0, the attributes were removed.

References

critical: 0 high: 1 medium: 0 low: 0 golang.org/x/oauth2 0.7.0 (golang)

pkg:golang/golang.org/x/oauth2@0.7.0

high 7.5: CVE--2025--22868 Improper Validation of Syntactic Correctness of Input

Affected range<0.27.0
Fixed version0.27.0
CVSS Score7.5
CVSS VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Score0.065%
EPSS Percentile21st percentile
Description

An attacker can pass a malicious malformed token which causes unexpected memory to be consumed during parsing.

critical: 0 high: 1 medium: 0 low: 0 c-ares 1.34.3-r0 (apk)

pkg:apk/alpine/c-ares@1.34.3-r0?os_name=alpine&os_version=3.21

high : CVE--2025--31498

Affected range<1.34.5-r0
Fixed version1.34.5-r0
EPSS Score0.154%
EPSS Percentile37th percentile
Description
critical: 0 high: 1 medium: 0 low: 0 github.com/golang-jwt/jwt 3.2.2+incompatible (golang)

pkg:golang/github.com/golang-jwt/jwt@3.2.2%2Bincompatible

high 8.7: CVE--2025--30204 Asymmetric Resource Consumption (Amplification)

Affected range>=3.2.0
<=3.2.2
Fixed versionNot Fixed
CVSS Score8.7
CVSS VectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
EPSS Score0.033%
EPSS Percentile8th percentile
Description

Summary

Function parse.ParseUnverified currently splits (via a call to strings.Split) its argument (which is untrusted data) on periods.

As a result, in the face of a malicious request whose Authorization header consists of Bearer followed by many period characters, a call to that function incurs allocations to the tune of O(n) bytes (where n stands for the length of the function's argument), with a constant factor of about 16. Relevant weakness: CWE-405: Asymmetric Resource Consumption (Amplification)

Details

See parse.ParseUnverified

Impact

Excessive memory allocation

Copy link

@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: 1

🧹 Nitpick comments (1)
.env.example (1)

39-46: Verify the QBO_API_URL endpoint and consider renaming for clarity.

The QBO_API_URL is set to the userinfo endpoint (https://sandbox-accounts.platform.intuit.com/v1/openid_connect/userinfo), which is specific to user information retrieval rather than a general API base URL. This might be confusing for developers.

Consider either:

  1. Renaming to QBO_USERINFO_URL for clarity
  2. Using the QBO base API URL (e.g., https://sandbox-quickbooks.api.intuit.com) if this is intended as a base URL
  3. Adding a comment explaining the specific purpose of this endpoint
-# QuickBooks Online (QBO) Configuration
-QBO_API_URL=https://sandbox-accounts.platform.intuit.com/v1/openid_connect/userinfo
+# QuickBooks Online (QBO) Configuration
+# OAuth2 userinfo endpoint for QBO integration
+QBO_USERINFO_URL=https://sandbox-accounts.platform.intuit.com/v1/openid_connect/userinfo
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b9da4f and f914da2.

📒 Files selected for processing (2)
  • .env.example (1 hunks)
  • workers/main/src/configs/qbo.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.env*

📄 CodeRabbit Inference Engine (.cursor/rules/service-configuration.mdc)

Create .env file from .env.example for environment configuration

Files:

  • .env.example
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/pull-request-rules.mdc:0-0
Timestamp: 2025-07-28T16:45:05.154Z
Learning: After the bullet list in the pull request body, add a brief explanation of why the PR is needed
Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/pull-request-rules.mdc:0-0
Timestamp: 2025-07-28T16:45:05.154Z
Learning: Pull request title must be a one sentence summary with a maximum of 120 characters
Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/pull-request-rules.mdc:0-0
Timestamp: 2025-07-28T16:45:05.154Z
Learning: Analyze the changes to understand the purpose and impact before submitting a pull request
Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/service-configuration.mdc:0-0
Timestamp: 2025-06-24T12:29:29.869Z
Learning: Environment configuration should be managed via a .env file, typically created from a provided .env.example template, to ensure consistent and secure configuration across environments.
Learnt from: anatolyshipitz
PR: speedandfunction/automatization#34
File: workers/main/src/workflows/financial/FinancialReportFormatter.ts:3-7
Timestamp: 2025-05-30T17:57:21.010Z
Learning: User anatolyshipitz prefers to keep code implementations simple during early development stages rather than adding comprehensive error handling and validation. They consider extensive type annotations and error handling "redundant" when focusing on core functionality and testing.
.env.example (1)

Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/service-configuration.mdc:0-0
Timestamp: 2025-06-24T12:29:29.869Z
Learning: Environment configuration should be managed via a .env file, typically created from a provided .env.example template, to ensure consistent and secure configuration across environments.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
  • GitHub Check: Service Availability Check
🔇 Additional comments (1)
workers/main/src/configs/qbo.ts (1)

14-23: Schema validation correctly supports both authentication methods.

The validation schema properly handles the transition from bearer token to OAuth2 authentication by making the bearer token optional while requiring OAuth2 credentials. The URL validation for the token endpoint is appropriate.

The schema changes align well with the OAuth2 integration requirements and maintain backward compatibility with existing bearer token setups.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 29, 2025
- Rearranged the QBO configuration parameters in `qbo.ts` for improved readability and consistency.
- Updated the Zod schema to enforce required fields for `QBO_API_URL`, `QBO_CLIENT_ID`, `QBO_CLIENT_SECRET`, and `QBO_COMPANY_ID`, while making `QBO_REFRESH_TOKEN` optional.
- This refactor enhances the clarity of the configuration setup and ensures that essential parameters are validated correctly.

These changes improve the overall structure and usability of the QBO integration configuration.
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 29, 2025
- Introduced additional QuickBooks Online (QBO) configuration parameters in the `.env.test` file, including `QBO_CLIENT_ID`, `QBO_CLIENT_SECRET`, `QBO_COMPANY_ID`, `QBO_REFRESH_TOKEN`, and `QBO_TOKEN_ENDPOINT`.
- This update enhances the environment setup for QBO integration by providing necessary configuration details for OAuth2 authentication in the testing environment.

These changes improve the clarity and usability of the environment configuration for developers working with the QBO API in testing scenarios.
Copy link

@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: 0

🧹 Nitpick comments (1)
workers/main/.env.test (1)

17-22: Add a trailing newline to satisfy dotenv-linter and POSIX tools

Many editors and linters (including dotenv-linter) expect a single LF at the end of the file.
Add one blank line after the last variable to silence the warning and avoid edge-case parsing issues.

 QBO_TOKEN_ENDPOINT=https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer
+
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 33b4ff8 and 554e2ac.

📒 Files selected for processing (1)
  • workers/main/.env.test (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/pull-request-rules.mdc:0-0
Timestamp: 2025-07-28T16:45:05.154Z
Learning: After the bullet list in the pull request body, add a brief explanation of why the PR is needed
Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/pull-request-rules.mdc:0-0
Timestamp: 2025-07-28T16:45:05.154Z
Learning: Pull request title must be a one sentence summary with a maximum of 120 characters
Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/pull-request-rules.mdc:0-0
Timestamp: 2025-07-28T16:45:05.154Z
Learning: Analyze the changes to understand the purpose and impact before submitting a pull request
Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/service-configuration.mdc:0-0
Timestamp: 2025-06-24T12:29:29.869Z
Learning: Environment configuration should be managed via a .env file, typically created from a provided .env.example template, to ensure consistent and secure configuration across environments.
Learnt from: anatolyshipitz
PR: speedandfunction/automatization#34
File: workers/main/src/workflows/financial/FinancialReportFormatter.ts:3-7
Timestamp: 2025-05-30T17:57:21.010Z
Learning: User anatolyshipitz prefers to keep code implementations simple during early development stages rather than adding comprehensive error handling and validation. They consider extensive type annotations and error handling "redundant" when focusing on core functionality and testing.
workers/main/.env.test (1)

Learnt from: CR
PR: speedandfunction/automatization#0
File: .cursor/rules/service-configuration.mdc:0-0
Timestamp: 2025-06-24T12:29:29.869Z
Learning: Environment configuration should be managed via a .env file, typically created from a provided .env.example template, to ensure consistent and secure configuration across environments.

🪛 dotenv-linter (3.3.0)
workers/main/.env.test

[warning] 22-22: [EndingBlankLine] No blank line at the end of the file

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
  • GitHub Check: Service Availability Check
🔇 Additional comments (1)
workers/main/.env.test (1)

14-22: Double-check coexistence of legacy bearer token with new OAuth2 flow

QBO_BEARER_TOKEN (lines 14–15) now coexists with the OAuth2 parameters added below.
Confirm that your updated qbo.ts schema really treats the bearer token as optional and that tests don’t unintentionally prefer the hard-coded token over the refresh-token flow; otherwise authentication paths may diverge between local, CI and production environments.

If the bearer token is no longer needed, consider removing it from .env.test to avoid confusion.

@sonarqubecloud
Copy link

Copy link
Contributor

@killev killev left a comment

Choose a reason for hiding this comment

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

Looks good

@anatolyshipitz anatolyshipitz merged commit 1d86d9f into main Jul 29, 2025
37 of 42 checks passed
@anatolyshipitz anatolyshipitz deleted the feature/65031_add_oauth2_parameters branch July 29, 2025 15:55
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.

3 participants