-
Notifications
You must be signed in to change notification settings - Fork 715
feat: Pipeline history endpoint and views composed on _meta org's triggers stream contents. #8902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
Implements a Pipeline History feature that mirrors the existing Alert History functionality, allowing users to view pipeline execution records from the _meta organization's triggers stream.
Key Changes
- Added
/api/{org_id}/pipelines/historyendpoint that queries the triggers stream withmodule='derived_stream'filter - Created new Vue component
PipelineHistory.vuewith datetime filtering, search, and pagination - Added route configuration and UI button in pipelines list to access history view
- Mirrored the existing alert history implementation pattern
Critical Issue Found
- SQL Injection Vulnerability: The
org_idparameter is directly interpolated into the SQL query without proper escaping (line 154-161 inhistory.rs), creating a security risk
Confidence Score: 2/5
- This PR has a critical SQL injection vulnerability that must be fixed before merging
- The SQL injection vulnerability in the history endpoint allows potential attackers to manipulate SQL queries through the org_id path parameter. While the rest of the implementation follows the existing alert history pattern and appears sound, this security issue is critical and blocks safe deployment.
- Critical:
src/handler/http/request/pipelines/history.rs- must fix SQL injection vulnerability before merge
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| src/handler/http/request/pipelines/history.rs | 2/5 | New endpoint for pipeline history with SQL injection vulnerability in org_id handling |
| src/handler/http/router/mod.rs | 5/5 | Registered new pipeline history endpoint in router |
| web/src/components/pipelines/PipelineHistory.vue | 4/5 | New Vue component for pipeline history display with datetime filtering and pagination |
Sequence Diagram
sequenceDiagram
participant User
participant Browser
participant PipelineHistory.vue
participant Router
participant API as /api/{org_id}/pipelines/history
participant Handler as get_pipeline_history
participant DB as list_pipelines
participant Search as SearchService
participant Meta as _meta org triggers stream
User->>Browser: Click "Pipeline History" button
Browser->>Router: Navigate to /pipelines/history
Router->>PipelineHistory.vue: Load component
PipelineHistory.vue->>API: GET /api/{org_id}/pipelines/history
Note over PipelineHistory.vue,API: Query params: start_time, end_time, from, size, pipeline_name
API->>Handler: Process request
Handler->>DB: list_pipelines(org_id)
DB-->>Handler: Return pipeline list
Note over Handler: Validate pipeline_name filter<br/>Build SQL query with org_id
Handler->>Search: SearchService.search(META_ORG_ID, sql)
Search->>Meta: Query triggers stream<br/>(module='derived_stream')
Meta-->>Search: Return execution records
Search-->>Handler: Return search results
Note over Handler: Parse hits, extract pipeline names<br/>from key field (name/id format)
Handler-->>API: PipelineHistoryResponse
API-->>PipelineHistory.vue: JSON response
PipelineHistory.vue-->>Browser: Render table with history
Browser-->>User: Display pipeline execution history
10 files reviewed, 1 comment
| let mut sql = format!( | ||
| "SELECT _timestamp, org, key, status, is_realtime, is_silenced, \ | ||
| start_time, end_time, retries, \ | ||
| delay_in_secs, evaluation_took_in_secs, \ | ||
| source_node, query_took \ | ||
| FROM \"{TRIGGERS_USAGE_STREAM}\" \ | ||
| WHERE module = 'derived_stream' AND org = '{org_id}' AND _timestamp >= {start_time} AND _timestamp <= {end_time}" | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: SQL injection vulnerability: org_id interpolated directly into query without escaping
| let mut sql = format!( | |
| "SELECT _timestamp, org, key, status, is_realtime, is_silenced, \ | |
| start_time, end_time, retries, \ | |
| delay_in_secs, evaluation_took_in_secs, \ | |
| source_node, query_took \ | |
| FROM \"{TRIGGERS_USAGE_STREAM}\" \ | |
| WHERE module = 'derived_stream' AND org = '{org_id}' AND _timestamp >= {start_time} AND _timestamp <= {end_time}" | |
| ); | |
| let mut sql = format!( | |
| "SELECT _timestamp, org, key, status, is_realtime, is_silenced, \ | |
| start_time, end_time, retries, \ | |
| delay_in_secs, evaluation_took_in_secs, \ | |
| source_node, query_took \ | |
| FROM \"{}\" \ | |
| WHERE module = 'derived_stream' AND org = '{}' AND _timestamp >= {} AND _timestamp <= {}", | |
| TRIGGERS_USAGE_STREAM, | |
| org_id.replace("'", "''"), | |
| start_time, | |
| end_time | |
| ); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/handler/http/request/pipelines/history.rs
Line: 154:161
Comment:
**logic:** SQL injection vulnerability: `org_id` interpolated directly into query without escaping
```suggestion
let mut sql = format!(
"SELECT _timestamp, org, key, status, is_realtime, is_silenced, \
start_time, end_time, retries, \
delay_in_secs, evaluation_took_in_secs, \
source_node, query_took \
FROM \"{}\" \
WHERE module = 'derived_stream' AND org = '{}' AND _timestamp >= {} AND _timestamp <= {}",
TRIGGERS_USAGE_STREAM,
org_id.replace("'", "''"),
start_time,
end_time
);
```
How can I resolve this? If you propose a fix, please make it concise.
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 346 | 0 | 19 | 1 | 95% | 4m 39s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 345 | 0 | 19 | 2 | 94% | 4m 38s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 344 | 0 | 19 | 3 | 94% | 4m 39s |
1fdd395 to
a6ca9f0
Compare
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 344 | 0 | 19 | 3 | 94% | 4m 39s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 344 | 0 | 19 | 3 | 94% | 4m 39s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 344 | 0 | 19 | 3 | 94% | 4m 39s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 344 | 0 | 19 | 3 | 94% | 4m 39s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 343 | 0 | 19 | 4 | 94% | 4m 39s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the labels part instead of directly keeping here , can you add them to en.json and you can use that t("alerts.name") direclty this
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 344 | 0 | 19 | 3 | 94% | 4m 38s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 343 | 0 | 19 | 4 | 94% | 4m 46s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 346 | 0 | 19 | 1 | 95% | 4m 39s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 344 | 0 | 19 | 3 | 94% | 4m 39s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 341 | 0 | 19 | 6 | 93% | 5m 41s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 339 | 0 | 19 | 8 | 93% | 5m 41s |
PR Type
Enhancement
Description
Implements a complete Pipeline History feature that allows users to view and analyse execution history of pipelines, mirroring the existing Alert History functionality.