Skip to content

Conversation

@anatolyshipitz
Copy link
Collaborator

@anatolyshipitz anatolyshipitz commented Jun 5, 2025

  • Deleted the fetchFinancialData.ts file as it was no longer needed.
  • Introduced getProjectUnits.ts to fetch project units and return a file link for the weekly financial reports.
  • Updated the weeklyFinancialReports workflow to utilize the new getProjectUnits function.
  • Added unit tests for the new workflow to ensure proper functionality.

@anatolyshipitz anatolyshipitz self-assigned this Jun 5, 2025
@anatolyshipitz anatolyshipitz requested a review from killev as a code owner June 5, 2025 16:18
@anatolyshipitz anatolyshipitz marked this pull request as draft June 5, 2025 16:18
@coderabbitai
Copy link

coderabbitai bot commented Jun 5, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The changes remove the previous financial data fetching stub and introduce a new workflow for retrieving project unit data from a Redmine database. New exports are added to the activities modules, and a function is implemented to fetch, serialize, and store project unit data, returning a file path to the saved JSON.

Changes

File(s) Change Summary
workers/main/src/activities/fetchFinancialData.ts Deleted the FinancialData interface and the fetchFinancialData async stub function.
workers/main/src/activities/index.ts Added export: re-exports all from ./weeklyFinancialReports.
workers/main/src/activities/weeklyFinancialReports/getProjectUnits.ts Added new async function getProjectUnits to fetch, serialize, and store project unit data.
workers/main/src/activities/weeklyFinancialReports/index.ts Added export: re-exports all from ./getProjectUnits.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant getProjectUnits
    participant RedmineDB
    participant TargetUnitRepository
    participant FileSystem

    Caller->>getProjectUnits: call()
    getProjectUnits->>RedmineDB: initialize connection pool
    getProjectUnits->>TargetUnitRepository: instantiate with pool
    getProjectUnits->>TargetUnitRepository: getTargetUnits()
    TargetUnitRepository-->>getProjectUnits: target units data
    getProjectUnits->>FileSystem: write JSON file (timestamped path)
    FileSystem-->>getProjectUnits: file path
    getProjectUnits-->>Caller: { fileLink }
Loading

Possibly related PRs

  • Implement TargetUnit repository #42: Deletes a stub for fetching generic financial data and adds functionality for retrieving and exporting project unit data via TargetUnitRepository, directly related to the repository and data retrieval logic introduced here.

Suggested reviewers

  • killev

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.

@github-actions
Copy link

github-actions bot commented Jun 5, 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.2 (golang)

pkg:golang/[email protected]

critical : CVE--2025--22871

Affected range<1.23.8
Fixed version1.23.8
EPSS Score0.018%
EPSS Percentile3rd 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.6 (golang)

pkg:golang/[email protected]

critical : CVE--2025--22871

Affected range<1.23.8
Fixed version1.23.8
EPSS Score0.018%
EPSS Percentile3rd 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 github.com/golang-jwt/jwt 3.2.2+incompatible (golang)

pkg:golang/github.com/golang-jwt/[email protected]%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.025%
EPSS Percentile5th 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/[email protected]#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.678%
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 c-ares 1.34.3-r0 (apk)

pkg:apk/alpine/[email protected]?os_name=alpine&os_version=3.21

high : CVE--2025--31498

Affected range<1.34.5-r0
Fixed version1.34.5-r0
EPSS Score0.147%
EPSS Percentile36th percentile
Description
critical: 0 high: 1 medium: 0 low: 0 golang.org/x/oauth2 0.26.0 (golang)

pkg:golang/golang.org/x/[email protected]

high : CVE--2025--22868

Affected range<0.27.0
Fixed version0.27.0
EPSS Score0.063%
EPSS Percentile20th 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/[email protected]#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.025%
EPSS Percentile5th 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 golang.org/x/crypto 0.32.0 (golang)

pkg:golang/golang.org/x/[email protected]

high : CVE--2025--22869

Affected range<0.35.0
Fixed version0.35.0
EPSS Score0.051%
EPSS Percentile16th 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.7.0 (golang)

pkg:golang/golang.org/x/[email protected]

high : CVE--2025--22868

Affected range<0.27.0
Fixed version0.27.0
EPSS Score0.063%
EPSS Percentile20th percentile
Description

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

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 (2)
workers/main/src/activities/weeklyFinancialReports/getProjectUnits.ts (2)

2-2: Consider consistent import formatting.

Mix of destructured and non-destructured imports. Consider using consistent formatting for better readability.

-import {TargetUnitRepository} from "../../services/TargetUnit/TargetUnitRepository";
+import { TargetUnitRepository } from "../../services/TargetUnit/TargetUnitRepository";

3-4: Consider consistent import formatting.

Mix of destructured and non-destructured imports. Consider using consistent formatting for better readability.

-import {RedminePool} from "../../common/RedminePool";
-import {redmineDatabaseConfig} from "../../configs/redmineDatabase";
+import { RedminePool } from "../../common/RedminePool";
+import { redmineDatabaseConfig } from "../../configs/redmineDatabase";
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1750080 and d892308.

📒 Files selected for processing (4)
  • workers/main/src/activities/fetchFinancialData.ts (0 hunks)
  • workers/main/src/activities/index.ts (1 hunks)
  • workers/main/src/activities/weeklyFinancialReports/getProjectUnits.ts (1 hunks)
  • workers/main/src/activities/weeklyFinancialReports/index.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • workers/main/src/activities/fetchFinancialData.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
workers/main/src/activities/weeklyFinancialReports/getProjectUnits.ts (3)
workers/main/src/common/RedminePool.ts (1)
  • RedminePool (4-46)
workers/main/src/configs/redmineDatabase.ts (1)
  • redmineDatabaseConfig (3-8)
workers/main/src/services/TargetUnit/TargetUnitRepository.ts (1)
  • TargetUnitRepository (9-52)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
  • GitHub Check: Docker Security Scanning (temporal, Dockerfile.temporal, temporal-test:latest)
  • GitHub Check: Service Availability Check
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
workers/main/src/activities/index.ts (1)

1-1: LGTM! Clean module organization.

The export statement follows standard practices for organizing module hierarchies and centralizing exports.

workers/main/src/activities/weeklyFinancialReports/index.ts (1)

1-1: LGTM! Consistent module organization.

The export statement maintains consistency with the module organization pattern.

@anatolyshipitz anatolyshipitz changed the base branch from main to feature/file-utils June 5, 2025 17:13
@anatolyshipitz anatolyshipitz marked this pull request as ready for review June 5, 2025 17:13
@anatolyshipitz anatolyshipitz force-pushed the issue/getProjectUnits branch from d892308 to dc4759d Compare June 5, 2025 17:14
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 changed the title Add getProjectUnits function for weekly financial reports Refactor weekly financial reports workflow Jun 5, 2025
…l data fetching

- Deleted the `fetchFinancialData.ts` file as it was no longer needed.
- Introduced `getTargetUnits.ts` to fetch target units and return a file link for weekly financial reports.
- Updated the `index.ts` files to export the new workflow structure.
- Removed outdated tests related to the previous financial data fetching logic.

These changes streamline the workflow for generating weekly financial reports by focusing on the retrieval of target units.
@anatolyshipitz anatolyshipitz force-pushed the issue/getProjectUnits branch from 8391c68 to 2d86d7c Compare June 5, 2025 17:53
- Introduced a new test file `getTargetUnits.test.ts` to validate the functionality of the `getTargetUnits` function.
- Implemented mocks for dependencies including `RedminePool`, `TargetUnitRepository`, and `writeJsonFile` to isolate tests.
- Added test cases to ensure successful retrieval of target units, error handling for repository failures, and proper file writing.
- Verified that the connection pool is always terminated after execution.

These additions enhance test coverage for the weekly financial reports workflow and ensure robust error handling in the `getTargetUnits` function.
- Updated the `getTargetUnits.test.ts` file to improve test coverage and structure.
- Introduced a mock setup for `TargetUnitRepository` and `RedminePool` to streamline testing.
- Refactored test cases for better clarity and added checks for error handling scenarios.
- Ensured that the connection pool is properly terminated after each test.

These changes strengthen the reliability of the `getTargetUnits` function and ensure comprehensive testing of its behavior.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 6, 2025

@anatolyshipitz anatolyshipitz requested a review from killev June 6, 2025 12:01
@anatolyshipitz anatolyshipitz merged commit 6b86a64 into feature/file-utils Jun 6, 2025
14 of 15 checks passed
@anatolyshipitz anatolyshipitz deleted the issue/getProjectUnits branch June 6, 2025 12:02
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