Skip to content

Fix Scan Pull Request failing tests#1240

Merged
eranturgeman merged 2 commits intojfrog:v3_erfrom
eranturgeman:fix-scan-pr-tests
Mar 3, 2026
Merged

Fix Scan Pull Request failing tests#1240
eranturgeman merged 2 commits intojfrog:v3_erfrom
eranturgeman:fix-scan-pr-tests

Conversation

@eranturgeman
Copy link
Collaborator

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • This pull request is on the dev branch.
  • I used gofmt for formatting the code before submitting the pull request.
  • Update documentation about new features / new supported technologies

@eranturgeman eranturgeman added the ignore for release Automatically generated release notes label Mar 3, 2026
@eranturgeman eranturgeman added the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@eranturgeman eranturgeman requested review from attiasas and orto17 March 3, 2026 14:46
Copy link
Contributor

@attiasas attiasas left a comment

Choose a reason for hiding this comment

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

LGTM

@eranturgeman eranturgeman added the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

🚨 Frogbot scanned this pull request and found the below:

📗 Scan Summary

  • Frogbot scanned for vulnerabilities and found 4 issues
Scan Category Status Security Issues
Software Composition Analysis ℹ️ Not Scanned -
Contextual Analysis ✅ Done -
Static Application Security Testing (SAST) ✅ Done
4 Issues Found 4 Medium
Secrets ✅ Done -
Infrastructure as Code (IaC) ✅ Done Not Found

repoFile, err := os.ReadFile(filepath.Join("..", params.RepoName, "targetBranch.gz"))
repoFile, err := os.ReadFile(filepath.Join(testDir, params.RepoName, "targetBranch.gz"))
assert.NoError(t, err)
_, err = w.Write(repoFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

🎯 Static Application Security Testing (SAST) Vulnerability

Severity Finding
medium
Medium
Untrusted stored value is included in web page content
Full description

Vulnerability Details

Rule ID: go-stored-xss

Overview

Stored Cross-Site Scripting (XSS) is a type of vulnerability where malicious
scripts are injected into a web application and stored in a persistent state,
such as a database. When other users access the affected page, the stored
scripts are executed in their browsers, leading to various attacks.

Vulnerable example

func serveMessage(w http.ResponseWriter, r *http.Request) {
    db, _ := sql.Open("sqlite3", "test.db")
    message := db.QueryRow("SELECT message FROM messages WHERE id = 1")
    fmt.Fprintf(w, "<h1>%s</h1>", message)
}

In this example, the serveMessage function retrieves a message from the
database and directly embeds it into an HTML response without proper escaping.
If the message contains malicious scripts, it can lead to Stored XSS attacks
when other users view the page.

Remediation

To mitigate Stored XSS vulnerabilities, always sanitize and encode user
input before storing it in a persistent state and before displaying it
to other users:

func serveMessage(w http.ResponseWriter, r *http.Request) {
    db, _ := sql.Open("sqlite3", "test.db")
    message := db.QueryRow("SELECT message FROM messages WHERE id = 1")
-   fmt.Fprintf(w, "<h1>%s</h1>", message)
+   fmt.Fprintf(w, "<h1>%s</h1>", html.EscapeString(message))
}

In the remediation, we've used the html.EscapeString function to escape
the message before embedding it into the HTML response. This helps prevent
the execution of malicious scripts and mitigates the Stored XSS vulnerability.

Code Flows
Vulnerable data flow analysis result

↘️ os.ReadFile(filepath.Join(testDir, params.RepoName, "targetBranch.gz")) (at scanpullrequest/scanpullrequest_test.go line 1398)

↘️ repoFile (at scanpullrequest/scanpullrequest_test.go line 1398)

↘️ repoFile (at scanpullrequest/scanpullrequest_test.go line 1400)




comments, err := os.ReadFile(filepath.Join("..", "commits.json"))
comments, err := os.ReadFile(filepath.Join(testDir, "commits.json"))
assert.NoError(t, err)
_, err = w.Write(comments)
Copy link
Contributor

Choose a reason for hiding this comment

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

🎯 Static Application Security Testing (SAST) Vulnerability

Severity Finding
medium
Medium
Untrusted stored value is included in web page content
Full description

Vulnerability Details

Rule ID: go-stored-xss

Overview

Stored Cross-Site Scripting (XSS) is a type of vulnerability where malicious
scripts are injected into a web application and stored in a persistent state,
such as a database. When other users access the affected page, the stored
scripts are executed in their browsers, leading to various attacks.

Vulnerable example

func serveMessage(w http.ResponseWriter, r *http.Request) {
    db, _ := sql.Open("sqlite3", "test.db")
    message := db.QueryRow("SELECT message FROM messages WHERE id = 1")
    fmt.Fprintf(w, "<h1>%s</h1>", message)
}

In this example, the serveMessage function retrieves a message from the
database and directly embeds it into an HTML response without proper escaping.
If the message contains malicious scripts, it can lead to Stored XSS attacks
when other users view the page.

Remediation

To mitigate Stored XSS vulnerabilities, always sanitize and encode user
input before storing it in a persistent state and before displaying it
to other users:

func serveMessage(w http.ResponseWriter, r *http.Request) {
    db, _ := sql.Open("sqlite3", "test.db")
    message := db.QueryRow("SELECT message FROM messages WHERE id = 1")
-   fmt.Fprintf(w, "<h1>%s</h1>", message)
+   fmt.Fprintf(w, "<h1>%s</h1>", html.EscapeString(message))
}

In the remediation, we've used the html.EscapeString function to escape
the message before embedding it into the HTML response. This helps prevent
the execution of malicious scripts and mitigates the Stored XSS vulnerability.

Code Flows
Vulnerable data flow analysis result

↘️ os.ReadFile(filepath.Join(testDir, "commits.json")) (at scanpullrequest/scanpullrequest_test.go line 1405)

↘️ comments (at scanpullrequest/scanpullrequest_test.go line 1405)

↘️ comments (at scanpullrequest/scanpullrequest_test.go line 1407)




discussions, err := os.ReadFile(filepath.Join("..", "list_merge_request_discussion_items.json"))
discussions, err := os.ReadFile(filepath.Join(testDir, "list_merge_request_discussion_items.json"))
assert.NoError(t, err)
_, err = w.Write(discussions)
Copy link
Contributor

Choose a reason for hiding this comment

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

🎯 Static Application Security Testing (SAST) Vulnerability

Severity Finding
medium
Medium
Untrusted stored value is included in web page content
Full description

Vulnerability Details

Rule ID: go-stored-xss

Overview

Stored Cross-Site Scripting (XSS) is a type of vulnerability where malicious
scripts are injected into a web application and stored in a persistent state,
such as a database. When other users access the affected page, the stored
scripts are executed in their browsers, leading to various attacks.

Vulnerable example

func serveMessage(w http.ResponseWriter, r *http.Request) {
    db, _ := sql.Open("sqlite3", "test.db")
    message := db.QueryRow("SELECT message FROM messages WHERE id = 1")
    fmt.Fprintf(w, "<h1>%s</h1>", message)
}

In this example, the serveMessage function retrieves a message from the
database and directly embeds it into an HTML response without proper escaping.
If the message contains malicious scripts, it can lead to Stored XSS attacks
when other users view the page.

Remediation

To mitigate Stored XSS vulnerabilities, always sanitize and encode user
input before storing it in a persistent state and before displaying it
to other users:

func serveMessage(w http.ResponseWriter, r *http.Request) {
    db, _ := sql.Open("sqlite3", "test.db")
    message := db.QueryRow("SELECT message FROM messages WHERE id = 1")
-   fmt.Fprintf(w, "<h1>%s</h1>", message)
+   fmt.Fprintf(w, "<h1>%s</h1>", html.EscapeString(message))
}

In the remediation, we've used the html.EscapeString function to escape
the message before embedding it into the HTML response. This helps prevent
the execution of malicious scripts and mitigates the Stored XSS vulnerability.

Code Flows
Vulnerable data flow analysis result

↘️ os.ReadFile(filepath.Join(testDir, "list_merge_request_discussion_items.json")) (at scanpullrequest/scanpullrequest_test.go line 1439)

↘️ discussions (at scanpullrequest/scanpullrequest_test.go line 1439)

↘️ discussions (at scanpullrequest/scanpullrequest_test.go line 1441)




repoFile, err := os.ReadFile(filepath.Join("..", params.RepoName, "sourceBranch.gz"))
repoFile, err := os.ReadFile(filepath.Join(testDir, params.RepoName, "sourceBranch.gz"))
assert.NoError(t, err)
_, err = w.Write(repoFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

🎯 Static Application Security Testing (SAST) Vulnerability

Severity Finding
medium
Medium
Untrusted stored value is included in web page content
Full description

Vulnerability Details

Rule ID: go-stored-xss

Overview

Stored Cross-Site Scripting (XSS) is a type of vulnerability where malicious
scripts are injected into a web application and stored in a persistent state,
such as a database. When other users access the affected page, the stored
scripts are executed in their browsers, leading to various attacks.

Vulnerable example

func serveMessage(w http.ResponseWriter, r *http.Request) {
    db, _ := sql.Open("sqlite3", "test.db")
    message := db.QueryRow("SELECT message FROM messages WHERE id = 1")
    fmt.Fprintf(w, "<h1>%s</h1>", message)
}

In this example, the serveMessage function retrieves a message from the
database and directly embeds it into an HTML response without proper escaping.
If the message contains malicious scripts, it can lead to Stored XSS attacks
when other users view the page.

Remediation

To mitigate Stored XSS vulnerabilities, always sanitize and encode user
input before storing it in a persistent state and before displaying it
to other users:

func serveMessage(w http.ResponseWriter, r *http.Request) {
    db, _ := sql.Open("sqlite3", "test.db")
    message := db.QueryRow("SELECT message FROM messages WHERE id = 1")
-   fmt.Fprintf(w, "<h1>%s</h1>", message)
+   fmt.Fprintf(w, "<h1>%s</h1>", html.EscapeString(message))
}

In the remediation, we've used the html.EscapeString function to escape
the message before embedding it into the HTML response. This helps prevent
the execution of malicious scripts and mitigates the Stored XSS vulnerability.

Code Flows
Vulnerable data flow analysis result

↘️ os.ReadFile(filepath.Join(testDir, params.RepoName, "sourceBranch.gz")) (at scanpullrequest/scanpullrequest_test.go line 1391)

↘️ repoFile (at scanpullrequest/scanpullrequest_test.go line 1391)

↘️ repoFile (at scanpullrequest/scanpullrequest_test.go line 1393)




@eranturgeman eranturgeman merged commit da09d8d into jfrog:v3_er Mar 3, 2026
21 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore for release Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants