step 2/2 opengrep scan --quiet --disable-version-check --config /opt/opengrep-rules --sarif-output="$GITBAY_RESULTS/opengrep.sarif" .
┌──────────────────┐
│ 91 Code Findings │
└──────────────────┘
Sources/OrgApp/SQLiteBlocks.swift
❯❱ opt.opengrep-rules.swift.sqllite.swift-potential-sqlite-injection
Potential Client-side SQL injection which has different impacts depending on the SQL use-case. The
impact may include the circumvention of local authentication mechanisms, obtaining of sensitive data
from the app, or manipulation of client-side behavior. It wasn't possible to make certain that the
source is untrusted, but the application should avoid concatenating dynamic data into SQL queries
and should instead leverage parameterized queries.
286┆ guard sqlite3_prepare_v2(db, "SELECT count(*) FROM
pragma_table_info('\(table.replacingOccurrences(of: "'", with: "''"))')", -1, &statement,
nil) == SQLITE_OK else {
⋮┆----------------------------------------
299┆ guard sqlite3_prepare_v2(db, insert, -1, &statement, nil) == SQLITE_OK else { throw
Refusal(.newTable) }
Sources/OrgCore/Config/ElispLibrary.swift
❯❱ opt.opengrep-rules.swift.lang.crypto.insecure-random
A random number generator was detected which is **not** *guaranteed* to be Cryptographically secure.
If the source of entropy is used for security purposes (e.g. with other Cryptographic operations),
make sure to use the `SecCopyRandomBytes` API explicitly.
66┆ return .integer(Int.random(in: 0..<n))
⋮┆----------------------------------------
68┆ return .integer(Int.random(in: -(1 << 61)...((1 << 61) - 1)))
Sources/TreeSitterElisp/src/tree_sitter/array.h
❯❱ opt.opengrep-rules.c.lang.security.insecure-use-memset
When handling sensitive information in a buffer, it's important to ensure that the data is securely
erased before the buffer is deleted or reused. While `memset()` is commonly used for this purpose,
it can leave sensitive information behind due to compiler optimizations or other factors. To avoid
this potential vulnerability, it's recommended to use the `memset_s()` function instead.
`memset_s()` is a standardized function that securely overwrites the memory with a specified value,
making it more difficult for an attacker to recover any sensitive data that was stored in the
buffer. By using `memset_s()` instead of `memset()`, you can help to ensure that your application
is more secure and less vulnerable to exploits that rely on residual data in memory.
▶▶┆ Autofix ▶ memset_s(contents + index * element_size), 0, new_count * element_size)
246┆ memset(
247┆ (contents + index * element_size),
248┆ 0,
249┆ new_count * element_size
250┆ );
Sources/TreeSitterScanners/javascript/tree_sitter/array.h
❯❱ opt.opengrep-rules.c.lang.security.insecure-use-memset
When handling sensitive information in a buffer, it's important to ensure that the data is securely
erased before the buffer is deleted or reused. While `memset()` is commonly used for this purpose,
it can leave sensitive information behind due to compiler optimizations or other factors. To avoid
this potential vulnerability, it's recommended to use the `memset_s()` function instead.
`memset_s()` is a standardized function that securely overwrites the memory with a specified value,
making it more difficult for an attacker to recover any sensitive data that was stored in the
buffer. By using `memset_s()` instead of `memset()`, you can help to ensure that your application
is more secure and less vulnerable to exploits that rely on residual data in memory.
▶▶┆ Autofix ▶ memset_s(contents + index * element_size), 0, new_count * element_size)
246┆ memset(
247┆ (contents + index * element_size),
248┆ 0,
249┆ new_count * element_size
250┆ );
Sources/TreeSitterScanners/lua/tree_sitter/array.h
❯❱ opt.opengrep-rules.c.lang.security.insecure-use-memset
When handling sensitive information in a buffer, it's important to ensure that the data is securely
erased before the buffer is deleted or reused. While `memset()` is commonly used for this purpose,
it can leave sensitive information behind due to compiler optimizations or other factors. To avoid
this potential vulnerability, it's recommended to use the `memset_s()` function instead.
`memset_s()` is a standardized function that securely overwrites the memory with a specified value,
making it more difficult for an attacker to recover any sensitive data that was stored in the
buffer. By using `memset_s()` instead of `memset()`, you can help to ensure that your application
is more secure and less vulnerable to exploits that rely on residual data in memory.
▶▶┆ Autofix ▶ memset_s(contents + index * element_size), 0, new_count * element_size)
283┆ memset(
284┆ (contents + index * element_size),
285┆ 0,
286┆ new_count * element_size
287┆ );
Sources/TreeSitterScanners/python/tree_sitter/array.h
❯❱ opt.opengrep-rules.c.lang.security.insecure-use-memset
When handling sensitive information in a buffer, it's important to ensure that the data is securely
erased before the buffer is deleted or reused. While `memset()` is commonly used for this purpose,
it can leave sensitive information behind due to compiler optimizations or other factors. To avoid
this potential vulnerability, it's recommended to use the `memset_s()` function instead.
`memset_s()` is a standardized function that securely overwrites the memory with a specified value,
making it more difficult for an attacker to recover any sensitive data that was stored in the
buffer. By using `memset_s()` instead of `memset()`, you can help to ensure that your application
is more secure and less vulnerable to exploits that rely on residual data in memory.
▶▶┆ Autofix ▶ memset_s(contents + index * element_size), 0, new_count * element_size)
246┆ memset(
247┆ (contents + index * element_size),
248┆ 0,
249┆ new_count * element_size
250┆ );
Sources/TreeSitterScanners/yaml/tree_sitter/array.h
❯❱ opt.opengrep-rules.c.lang.security.insecure-use-memset
When handling sensitive information in a buffer, it's important to ensure that the data is securely
erased before the buffer is deleted or reused. While `memset()` is commonly used for this purpose,
it can leave sensitive information behind due to compiler optimizations or other factors. To avoid
this potential vulnerability, it's recommended to use the `memset_s()` function instead.
`memset_s()` is a standardized function that securely overwrites the memory with a specified value,
making it more difficult for an attacker to recover any sensitive data that was stored in the
buffer. By using `memset_s()` instead of `memset()`, you can help to ensure that your application
is more secure and less vulnerable to exploits that rely on residual data in memory.
▶▶┆ Autofix ▶ memset_s(contents + index * element_size), 0, new_count * element_size)
246┆ memset(
247┆ (contents + index * element_size),
248┆ 0,
249┆ new_count * element_size
250┆ );
Tests/OrgCoreTests/CalcNumericTests.swift
❯❱ opt.opengrep-rules.swift.lang.crypto.insecure-random
A random number generator was detected which is **not** *guaranteed* to be Cryptographically secure.
If the source of entropy is used for security purposes (e.g. with other Cryptographic operations),
make sure to use the `SecCopyRandomBytes` API explicitly.
9┆ let sign = Bool.random(using: &generator) ? "-" : ""
⋮┆----------------------------------------
10┆ let digits = Int.random(in: 1...9, using: &generator)
⋮┆----------------------------------------
11┆ let mantissa = String(Int.random(in: 1...999_999_999, using: &generator)).prefix(digits)
⋮┆----------------------------------------
12┆ switch Int.random(in: 0..<5, using: &generator) {
⋮┆----------------------------------------
13┆ case 0: return sign + String(Int.random(in: 0...(scale > 2 ? 720 : 70), using: &generator))
⋮┆----------------------------------------
14┆ case 1: return sign + "\(Int.random(in: 1...99, using: &generator)):\(Int.random(in:
2...99, using: &generator))"
⋮┆----------------------------------------
14┆ case 1: return sign + "\(Int.random(in: 1...99, using: &generator)):\(Int.random(in:
2...99, using: &generator))"
⋮┆----------------------------------------
15┆ case 2: return sign + "\(mantissa)e\(Int.random(in: -30...(scale - mantissa.count), using:
&generator))"
⋮┆----------------------------------------
16┆ case 3: return sign + "\(mantissa)e\(Int.random(in: -mantissa.count - 1...(scale -
mantissa.count), using: &generator))"
⋮┆----------------------------------------
24┆ let sign = Bool.random(using: &generator) ? "-" : ""
⋮┆----------------------------------------
25┆ let mantissa = String(Int.random(in: 1...999_999_999, using:
&generator)).prefix(Int.random(in: 1...9, using: &generator))
⋮┆----------------------------------------
25┆ let mantissa = String(Int.random(in: 1...999_999_999, using:
&generator)).prefix(Int.random(in: 1...9, using: &generator))
⋮┆----------------------------------------
26┆ switch Int.random(in: 0..<4, using: &generator) {
⋮┆----------------------------------------
29┆ let d = Int.random(in: 2...99, using: &generator)
⋮┆----------------------------------------
30┆ return sign + "\(Int.random(in: 1..<d, using: &generator)):\(d)"
⋮┆----------------------------------------
38┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
92┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
96┆ func vector() -> String { "[" + (0..<Int.random(in: 1...5, using: &generator)).map { _ in
number() }.joined(separator: ",") + "]" }
⋮┆----------------------------------------
107┆ switch Int.random(in: 0..<4, using: &generator) {
Tests/OrgCoreTests/CalcTests.swift
❯❱ opt.opengrep-rules.swift.lang.crypto.insecure-random
A random number generator was detected which is **not** *guaranteed* to be Cryptographically secure.
If the source of entropy is used for security purposes (e.g. with other Cryptographic operations),
make sure to use the `SecCopyRandomBytes` API explicitly.
272┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
277┆ for _ in 0..<Int.random(in: 1...4, using: &generator) {
⋮┆----------------------------------------
297┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
314┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
338┆ let x = "\(Int.random(in: 1...999, using: &generator))e-2"
⋮┆----------------------------------------
345┆ for _ in 0..<Int.random(in: 1...3, using: &generator) {
⋮┆----------------------------------------
402┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
406┆ if depth == 0 || Int.random(in: 0..<3, using: &generator) == 0 { return
leaves.randomElement(using: &generator)! }
⋮┆----------------------------------------
410┆ return Int.random(in: 0..<6, using: &generator) == 0 ? "-\(e)" : e
⋮┆----------------------------------------
458┆ func operand(_ e: String) -> String { Int.random(in: 0..<10, using: &generator) < 7 ? e :
"(\(e))" }
⋮┆----------------------------------------
460┆ if depth == 0 || Int.random(in: 0..<4, using: &generator) == 0 { return leaf() }
⋮┆----------------------------------------
461┆ switch Int.random(in: 0..<10, using: &generator) {
⋮┆----------------------------------------
472┆ let items = (0..<Int.random(in: 0...3, using: &generator)).map { _ in expression(depth - 1)
}
Tests/OrgCoreTests/IncrementalTests.swift
❯❱ opt.opengrep-rules.swift.lang.crypto.insecure-random
A random number generator was detected which is **not** *guaranteed* to be Cryptographically secure.
If the source of entropy is used for security purposes (e.g. with other Cryptographic operations),
make sure to use the `SecCopyRandomBytes` API explicitly.
103┆ let b = Bool.random(using: &rng) ? a : later.randomElement(using: &rng)!
⋮┆----------------------------------------
105┆ if Int.random(in: 0..<10, using: &rng) < 7 {
⋮┆----------------------------------------
106┆ replacement = (0..<Int.random(in: 0...2, using: &rng)).map { _ in
small.randomElement(using: &rng)! }.joined()
⋮┆----------------------------------------
108┆ replacement = fragments.randomElement(using: &rng)! + (Bool.random(using: &rng) ? "\n" :
"")
Tests/OrgCoreTests/ListItemScanTests.swift
❯❱ opt.opengrep-rules.swift.lang.crypto.insecure-random
A random number generator was detected which is **not** *guaranteed* to be Cryptographically secure.
If the source of entropy is used for security purposes (e.g. with other Cryptographic operations),
make sure to use the `SecCopyRandomBytes` API explicitly.
11┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
15┆ let count = Int.random(in: 1...7, using: &generator)
Tests/OrgCoreTests/RoundTripTests.swift
❯❱ opt.opengrep-rules.swift.lang.crypto.insecure-random
A random number generator was detected which is **not** *guaranteed* to be Cryptographically secure.
If the source of entropy is used for security purposes (e.g. with other Cryptographic operations),
make sure to use the `SecCopyRandomBytes` API explicitly.
32┆ (0..<Int.random(in: 0...40, using: &rng)).map { _ in
⋮┆----------------------------------------
33┆ fragments.randomElement(using: &rng)! + (Bool.random(using: &rng) ? "\n" : "")
Tests/OrgEditorAppKitTests/LineIndexTests.swift
❯❱ opt.opengrep-rules.swift.lang.crypto.insecure-random
A random number generator was detected which is **not** *guaranteed* to be Cryptographically secure.
If the source of entropy is used for security purposes (e.g. with other Cryptographic operations),
make sure to use the `SecCopyRandomBytes` API explicitly.
14┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
20┆ let start = Int.random(in: 0...ns.length, using: &generator)
⋮┆----------------------------------------
37┆ var generator = SystemRandomNumberGenerator()
⋮┆----------------------------------------
42┆ let start = Int.random(in: 0...length, using: &generator)
docs/manual/templates/base.html
❯❱ opt.opengrep-rules.generic.html-templates.security.var-in-href
Detected a template variable used in an anchor tag with the 'href' attribute. This allows a
malicious actor to input the 'javascript:' URI and is subject to cross- site scripting (XSS)
attacks. If using Flask, use 'url_for()' to safely generate a URL. If using Django, use the 'url'
filter to safely generate a URL. If using Mustache, use a URL encoding library, or prepend a slash
'/' to the variable for relative links (`href="/{{link}}"`). You may also consider setting the
Content Security Policy (CSP) header.
26┆ <a href="{{ item.url }}">{{ item.title }}</a>
❯❱ opt.opengrep-rules.python.flask.security.xss.audit.template-unescaped-with-safe
Detected a segment of a Flask template where autoescaping is explicitly disabled with '| safe'
filter. This allows rendering of raw HTML in this segment. Ensure no user data is rendered here,
otherwise this is a cross-site scripting (XSS) vulnerability.
50┆ {% block content %}{{ body | safe }}{% endblock %}</main>
docs/manual/templates/list.html
❯❱ opt.opengrep-rules.generic.html-templates.security.var-in-href
Detected a template variable used in an anchor tag with the 'href' attribute. This allows a
malicious actor to input the 'javascript:' URI and is subject to cross- site scripting (XSS)
attacks. If using Flask, use 'url_for()' to safely generate a URL. If using Django, use the 'url'
filter to safely generate a URL. If using Mustache, use a URL encoding library, or prepend a slash
'/' to the variable for relative links (`href="/{{link}}"`). You may also consider setting the
Content Security Policy (CSP) header.
6┆ <a href="{{ root }}{{ entry.url }}">{{ entry.title }}</a>
packaging/license-issuer/worker.js
❯❱ opt.opengrep-rules.javascript.lang.correctness.no-stringify-keys
JSON stringify does not produce a stable key ordering, and should not be relied on for producing
object keys. Consider using json-stable-stringify instead.
43┆ if (!(value > 0)) throw new Error(`${name} must be a positive number, not
${JSON.stringify(env[name])}`);
❯❱ opt.opengrep-rules.javascript.lang.security.html-in-template-string
This template literal looks like HTML and has interpolated variables. These variables are not HTML-
encoded by default. If the variables contain HTML tags, these may be interpreted by the browser,
resulting in cross-site scripting (XSS).
66┆ const features = FEATURES.map((feature) => `<li>${feature}</li>`).join("");
⋮┆----------------------------------------
69┆ `clocking, tables and search stay free.</p><ul>${features}</ul>` +
⋮┆----------------------------------------
70┆ `<ul class="tiers"><li><b>$${lifetime} once</b>: a license key that doesn't expire.</li>` +
⋮┆----------------------------------------
71┆ `<li><b>$${monthly} a month</b>: a key that orgstar renews while you sponsor.</li></ul>` +
⋮┆----------------------------------------
72┆ `<p><a class="button" href="https://github.com/sponsors/${sponsorable}">Sponsor on
GitHub</a></p>` +
⋮┆----------------------------------------
73┆ `<p>Then <a href="${new URL("license", url)}">sign in with GitHub to get your key</a>.</p>`
+
⋮┆----------------------------------------
103┆ return page(`The sign-in expired. <a href="${self}">Sign in again</a>.`, 400);
⋮┆----------------------------------------
111┆ if (!token) return page(`GitHub didn't complete the sign-in. <a href="${self}">Try
again</a>.`, 502);
❱ opt.opengrep-rules.javascript.lang.correctness.missing-template-string-indicator
This looks like a JavaScript template string. Are you missing a '$' in front of '{...}'?
115┆ `query($login: String!) {
116┆ viewer { id login }
117┆ owner: repositoryOwner(login: $login) {
118┆ ... on Sponsorable {
119┆ sponsorshipForViewerAsSponsor(activeOnly: false) {
120┆ isActive createdAt tier { monthlyPriceInDollars isOneTime }
121┆ }
122┆ }
123┆ }
124┆ }`,
⋮┆----------------------------------------
115┆ `query($login: String!) {
116┆ viewer { id login }
117┆ owner: repositoryOwner(login: $login) {
118┆ ... on Sponsorable {
119┆ sponsorshipForViewerAsSponsor(activeOnly: false) {
120┆ isActive createdAt tier { monthlyPriceInDollars isOneTime }
121┆ }
122┆ }
123┆ }
124┆ }`,
❯❱ opt.opengrep-rules.javascript.lang.security.html-in-template-string
This template literal looks like HTML and has interpolated variables. These variables are not HTML-
encoded by default. If the variables contain HTML tags, these may be interpreted by the browser,
resulting in cross-site scripting (XSS).
137┆ `or $${config.monthly} or more a month. <a href="${sponsor}">Sponsor on GitHub</a>, then
come back to this page.`,
⋮┆----------------------------------------
152┆ `<p>Your orgstar+ license key:</p><pre>${key}</pre>` +
⋮┆----------------------------------------
153┆ `<p>In orgstar, open Settings ▸ orgstar+, paste the key and choose Activate. ${note}</p>`,
❱ opt.opengrep-rules.javascript.lang.correctness.missing-template-string-indicator
This looks like a JavaScript template string. Are you missing a '$' in front of '{...}'?
279┆ `<title>${heading}</title><style>body{font:16px/1.5 system-ui;max-width:40rem;margin:3rem
auto;padding:0 1rem}` +
❯❱ opt.opengrep-rules.javascript.lang.security.html-in-template-string
This template literal looks like HTML and has interpolated variables. These variables are not HTML-
encoded by default. If the variables contain HTML tags, these may be interpreted by the browser,
resulting in cross-site scripting (XSS).
279┆ `<title>${heading}</title><style>body{font:16px/1.5 system-ui;max-width:40rem;margin:3rem
auto;padding:0 1rem}` +
❱ opt.opengrep-rules.javascript.lang.correctness.missing-template-string-indicator
This looks like a JavaScript template string. Are you missing a '$' in front of '{...}'?
279┆ `<title>${heading}</title><style>body{font:16px/1.5 system-ui;max-width:40rem;margin:3rem
auto;padding:0 1rem}` +
⋮┆----------------------------------------
280┆ `pre{white-space:pre-wrap;word-break:break-all;background:#f4f4f4;padding:1rem;border-
radius:6px}` +
⋮┆----------------------------------------
280┆ `pre{white-space:pre-wrap;word-break:break-all;background:#f4f4f4;padding:1rem;border-
radius:6px}` +
⋮┆----------------------------------------
281┆ `.tiers{list-style:none;padding:0}.note{color:#666;font-size:.9rem}` +
⋮┆----------------------------------------
281┆ `.tiers{list-style:none;padding:0}.note{color:#666;font-size:.9rem}` +
⋮┆----------------------------------------
282┆ `.button{display:inline-block;font-weight:600;padding:.7rem 1.4rem;border-
radius:8px;background:#d4a017;color:#fff;text-decoration:none}</style>` +
⋮┆----------------------------------------
282┆ `.button{display:inline-block;font-weight:600;padding:.7rem 1.4rem;border-
radius:8px;background:#d4a017;color:#fff;text-decoration:none}</style>` +
❯❱ opt.opengrep-rules.javascript.lang.security.html-in-template-string
This template literal looks like HTML and has interpolated variables. These variables are not HTML-
encoded by default. If the variables contain HTML tags, these may be interpreted by the browser,
resulting in cross-site scripting (XSS).
283┆ `<h1>${heading}</h1>${body.startsWith("<") ? body : `<p>${body}</p>`}`;
⋮┆----------------------------------------
283┆ `<h1>${heading}</h1>${body.startsWith("<") ? body : `<p>${body}</p>`}`;
packaging/license-issuer/wrangler.toml
❱ opt.opengrep-rules.generic.secrets.gitleaks.generic-api-key
A gitleaks generic-api-key was detected which attempts to identify hard-coded credentials. It is
not recommended to store credentials in source-code, as this risks secrets being leaked and used by
either an internal or external malicious adversary. It is recommended to use environment variables
to securely provide credentials or retrieve credentials from a secure vault or HSM (Hardware
Security Module). This rule can introduce a lot of false positives, it is not recommended to be
used in PR comments.
17┆ GITHUB_CLIENT_ID = "Ov23li0VjIFjZYslRU51"
scripts/build-app.sh
❱ opt.opengrep-rules.bash.lang.correctness.unquoted-variable-expansion-in-command
Variable expansions must be double-quoted so as to prevent being split into multiple pieces
according to whitespace or whichever separator is specified by the IFS variable. If you really wish
to split the variable's contents, you may use a variable that starts with an underscore e.g. $_X
instead of $X, and semgrep will ignore it. If what you need is an array, consider using a proper
bash array.
24┆ swift build -c release $arch_flags --product Orgstar
⋮┆----------------------------------------
26┆ swift build -c release $arch_flags --product OrgstarQuickLook
⋮┆----------------------------------------
28┆ swift build -c release $arch_flags --product OrgstarSpotlight
⋮┆----------------------------------------
30┆ swift build -c release $arch_flags --product OrgstarWidgets
⋮┆----------------------------------------
32┆ binary="$(swift build -c release $arch_flags --show-bin-path)/Orgstar"
⋮┆----------------------------------------
222┆ codesign --force --sign "$sign" $sign_flags --entitlements "$work/sandbox.entitlements"
"$app/Contents/PlugIns/$1.appex"
⋮┆----------------------------------------
238┆ codesign --force --sign "$sign" $sign_flags "$item"
⋮┆----------------------------------------
253┆ codesign --force --sign "$sign" $sign_flags --entitlements "$work/app.entitlements" "$app"
scripts/build-ios-app.sh
❱ opt.opengrep-rules.bash.lang.correctness.unquoted-variable-expansion-in-command
Variable expansions must be double-quoted so as to prevent being split into multiple pieces
according to whitespace or whichever separator is specified by the IFS variable. If you really wish
to split the variable's contents, you may use a variable that starts with an underscore e.g. $_X
instead of $X, and semgrep will ignore it. If what you need is an array, consider using a proper
bash array.
172┆ codesign --force --sign - ${6:+--entitlements "$6"} "$dir"
results uploaded