Skip to content

Commit ecc042a

Browse files
authored
Merge branch 'main' into develop
2 parents 31710c8 + 29a27c5 commit ecc042a

File tree

8 files changed

+59
-47
lines changed

8 files changed

+59
-47
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
commit = True
33
tag = False
44
message = Bump version: {current_version} → {new_version}
5-
current_version = 5.1.7
5+
current_version = 5.1.8
66

77
[bumpversion:file:setup.py]
88
search = '{current_version}'

.github/workflows/publish-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ jobs:
6262
TARGET: ubuntu
6363
CMD_BUILD: >
6464
pyinstaller --onefile cli.py -n cli --additional-hooks-dir=hooks --hidden-import=pkg_resources.extern --add-binary "LICENSE:LICENSES" --add-binary "LICENSES/LicenseRef-3rd_party_licenses.txt:LICENSES" &&
65-
mv dist/cli fosslight_bin_ubuntu18
66-
OUT_FILE_NAME: fosslight_bin_ubuntu18
65+
mv dist/cli fosslight_bin_ubuntu
66+
OUT_FILE_NAME: fosslight_bin_ubuntu
6767
ASSET_MIME: application/octet-stream
6868
- os: macos-latest
6969
TARGET: macos

.github/workflows/pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ jobs:
4040
python-version: [3.12.x]
4141
steps:
4242
- uses: actions/checkout@v3
43-
- name: Set up Python 3.12
43+
- name: Set up Python ${{ matrix.python-version }}
4444
uses: actions/setup-python@v4
4545
with:
46-
python-version: '3.12.x'
46+
python-version: ${{ matrix.python-version }}
4747
- name: Install & Run
4848
run: |
4949
python -m pip install --upgrade pip

CHANGELOG.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## v5.1.8 (17/07/2025)
4+
## Changes
5+
## 🐛 Hotfixes
6+
7+
- Remove SQL injection vulnerability @bjk7119 (#150)
8+
9+
## 🔧 Maintenance
10+
11+
- Change the minimum Python version to 3.10 @bjk7119 (#151)
12+
- Remove the duplicated comment @bjk7119 (#146)
13+
- Fix workflow waring message @bjk7119 (#145)
14+
15+
---
16+
317
## v5.1.7 (25/05/2025)
418
## Changes
519
## 🔧 Maintenance
@@ -290,11 +304,3 @@
290304
## 🔧 Maintenance
291305

292306
- Modify not to generate binary.txt if no binaries @dd-jy (#76)
293-
294-
---
295-
296-
## v4.1.13 (04/11/2022)
297-
## Changes
298-
## 🔧 Maintenance
299-
300-
- Print license text through notice parameter @dd-jy (#75)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ binaryornot
22
numpy
33
pandas
44
parmap
5-
psycopg2-binary==2.9.9
5+
psycopg2-binary
66
python-dateutil
77
py-tlsh
88
pytz

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
setup(
3535
name=_PACKAEG_NAME,
36-
version='5.1.7',
36+
version='5.1.8',
3737
package_dir={"": "src"},
3838
packages=find_packages(where='src'),
3939
description='FOSSLight Binary Scanner',
@@ -45,10 +45,10 @@
4545
download_url='https://github.com/fosslight/fosslight_binary_scanner',
4646
classifiers=['License :: OSI Approved :: Apache Software License',
4747
"Programming Language :: Python :: 3",
48-
"Programming Language :: Python :: 3.6",
49-
"Programming Language :: Python :: 3.7",
50-
"Programming Language :: Python :: 3.8",
51-
"Programming Language :: Python :: 3.9", ],
48+
"Programming Language :: Python :: 3.10",
49+
"Programming Language :: Python :: 3.11",
50+
"Programming Language :: Python :: 3.12"],
51+
python_requires='>=3.10,<3.13',
5252
install_requires=install_requires,
5353
extras_require={
5454
':sys_platform == "win32"': [

src/fosslight_binary/_binary_dao.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,20 @@ def get_connection_string(dburl):
8989
def get_oss_info_by_tlsh_and_filename(file_name, checksum_value, tlsh_value):
9090
sql_statement = "SELECT filename,pathname,checksum,tlshchecksum,ossname,ossversion,\
9191
license,platformname,platformversion FROM lgematching "
92-
sql_statement_checksum = " WHERE filename='{fname}' AND checksum='{checksum}';".format(fname=file_name,
93-
checksum=checksum_value) # Checking checksum first.
94-
sql_statement_filename = "SELECT DISTINCT ON (tlshchecksum) tlshchecksum FROM lgematching WHERE filename='{fname}';".format(
95-
fname=file_name) # For getting tlsh values of file.
92+
sql_statement_checksum = " WHERE filename=%s AND checksum=%s;" # Using parameterized query
93+
sql_statement_filename = "SELECT DISTINCT ON (tlshchecksum) tlshchecksum FROM lgematching WHERE filename=%s;" # Using parameterized query
9694

9795
final_result_item = ""
9896

9997
df_result = get_list_by_using_query(
100-
sql_statement + sql_statement_checksum, columns)
98+
sql_statement + sql_statement_checksum, columns, (file_name, checksum_value))
10199
# Found a file with the same checksum.
102100
if df_result is not None and len(df_result) > 0:
103101
final_result_item = df_result
104102
else:
105103
# Match tlsh and fileName
106104
df_result = get_list_by_using_query(
107-
sql_statement_filename, ['tlshchecksum'])
105+
sql_statement_filename, ['tlshchecksum'], (file_name,))
108106
if df_result is None or len(df_result) <= 0:
109107
final_result_item = ""
110108
elif tlsh_value == TLSH_CHECKSUM_NULL: # Couldn't get the tlsh of a file.
@@ -124,20 +122,25 @@ def get_oss_info_by_tlsh_and_filename(file_name, checksum_value, tlsh_value):
124122
logger.warning(f"* (Minor) Error_tlsh_comparison: {ex}")
125123
if matched_tlsh != "":
126124
final_result_item = get_list_by_using_query(
127-
sql_statement + " WHERE filename='{fname}' AND tlshchecksum='{tlsh}';".format(fname=file_name,
128-
tlsh=matched_tlsh),
129-
columns)
125+
sql_statement + " WHERE filename=%s AND tlshchecksum=%s;", columns, (file_name, matched_tlsh))
130126

131127
return final_result_item
132128

133129

134-
def get_list_by_using_query(sql_query, columns):
130+
def get_list_by_using_query(sql_query, columns, params=None):
135131
result_rows = "" # DataFrame
136-
cur.execute(sql_query)
137-
rows = cur.fetchall()
132+
try:
133+
if params:
134+
cur.execute(sql_query, params)
135+
else:
136+
cur.execute(sql_query)
137+
rows = cur.fetchall()
138138

139-
if rows is not None and len(rows) > 0:
140-
result_rows = pd.DataFrame(data=rows, columns=columns)
139+
if rows is not None and len(rows) > 0:
140+
result_rows = pd.DataFrame(data=rows, columns=columns)
141+
except Exception as ex:
142+
logger.error(f"Database query error: {ex}")
143+
result_rows = ""
141144
return result_rows
142145

143146

src/fosslight_binary/_jar_analysis.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -270,20 +270,23 @@ def analyze_jar_file(path_to_find_bin, path_to_exclude):
270270
# Get Vulnerability Info.
271271
vulnerability_items = get_vulnerability_info(file_with_path, vulnerability, vulnerability_items, remove_vulnerability_items)
272272

273-
if oss_name != "" or oss_ver != "" or oss_license != "" or oss_dl_url != "":
274-
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
275-
oss.comment = "OWASP result"
276-
277-
if file_with_path in owasp_items:
278-
owasp_items[file_with_path]["oss_list"].append(oss)
279-
# Update sha1 if not already set or if current sha1 is empty
280-
if not owasp_items[file_with_path]["sha1"] and sha1:
281-
owasp_items[file_with_path]["sha1"] = sha1
282-
else:
283-
owasp_items[file_with_path] = {
284-
"oss_list": [oss],
285-
"sha1": sha1
286-
}
273+
if oss_name or oss_license or oss_dl_url:
274+
oss_list_for_file = owasp_items.get(file_with_path, [])
275+
276+
existing_oss = None
277+
for item in oss_list_for_file:
278+
if item.name == oss_name and item.version == oss_ver:
279+
existing_oss = item
280+
break
281+
282+
if not existing_oss:
283+
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
284+
oss.comment = "OWASP result"
285+
286+
if file_with_path in owasp_items:
287+
owasp_items[file_with_path].append(oss)
288+
else:
289+
owasp_items[file_with_path] = [oss]
287290
except Exception as ex:
288291
logger.debug(f"Error to get dependency Info in jar_contents: {ex}")
289292

0 commit comments

Comments
 (0)