-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'dist' to the default exclusion patterns (#248)
- Loading branch information
1 parent
e54708a
commit ac30b34
Showing
5 changed files
with
124 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
tests/testdata/projects/jas/jas/sast/flask_webgoat/dist/init_file_to_ignore.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copy of __init__ - inside the dist folder - which we expect not to be scanned | ||
|
||
import os | ||
import sqlite3 | ||
from pathlib import Path | ||
|
||
from flask import Flask, g | ||
|
||
DB_FILENAME = "database.db" | ||
|
||
|
||
def query_db(query, args=(), one=False, commit=False): | ||
with sqlite3.connect(DB_FILENAME) as conn: | ||
# vulnerability: Sensitive Data Exposure | ||
conn.set_trace_callback(print) | ||
cur = conn.cursor().execute(query, args) | ||
if commit: | ||
conn.commit() | ||
return cur.fetchone() if one else cur.fetchall() | ||
|
||
|
||
def create_app(): | ||
app = Flask(__name__) | ||
# jfrog-ignore - disable secrets scan findings | ||
app.secret_key = "aeZ1iwoh2ree2mo0Eereireong4baitixaixu5Ee" | ||
|
||
db_path = Path(DB_FILENAME) | ||
if db_path.exists(): | ||
db_path.unlink() | ||
|
||
conn = sqlite3.connect(DB_FILENAME) | ||
create_table_query = """CREATE TABLE IF NOT EXISTS user | ||
(id INTEGER PRIMARY KEY, username TEXT, password TEXT, access_level INTEGER)""" | ||
conn.execute(create_table_query) | ||
|
||
insert_admin_query = """INSERT INTO user (id, username, password, access_level) | ||
VALUES (1, 'admin', 'admin', 0)""" | ||
conn.execute(insert_admin_query) | ||
conn.commit() | ||
conn.close() | ||
|
||
with app.app_context(): | ||
from . import actions | ||
from . import auth | ||
from . import status | ||
from . import ui | ||
from . import users | ||
|
||
app.register_blueprint(actions.bp) | ||
app.register_blueprint(auth.bp) | ||
app.register_blueprint(status.bp) | ||
app.register_blueprint(ui.bp) | ||
app.register_blueprint(users.bp) | ||
return app |
20 changes: 20 additions & 0 deletions
20
tests/testdata/projects/package-managers/dotnet/dotnet-single/sample_sast_vulnerability.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.IO; | ||
using System.Web; | ||
|
||
public class TaintedPathHandler : IHttpHandler | ||
{ | ||
public void ProcessRequest(HttpContext ctx) | ||
{ | ||
String path = ctx.Request.QueryString["path"]; | ||
// BAD: This could read any file on the filesystem. | ||
ctx.Response.Write(File.ReadAllText(path)); | ||
|
||
// BAD: This could still read any file on the filesystem. | ||
ctx.Response.Write(File.ReadAllText("/home/user/" + path)); | ||
|
||
// GOOD: MapPath ensures the path is safe to read from. | ||
string safePath = ctx.Request.MapPath(path, ctx.Request.ApplicationPath, false); | ||
ctx.Response.Write(File.ReadAllText(safePath)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters