mirror of
https://github.com/hanzoui/custom-nodes-security-scan.git
synced 2026-10-30 20:56:54 +00:00
390 lines
13 KiB
HTML
390 lines
13 KiB
HTML
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>
|
|
Bandit Report
|
|
</title>
|
|
|
|
<style>
|
|
|
|
html * {
|
|
font-family: "Arial", sans-serif;
|
|
}
|
|
|
|
pre {
|
|
font-family: "Monaco", monospace;
|
|
}
|
|
|
|
.bordered-box {
|
|
border: 1px solid black;
|
|
padding-top:.5em;
|
|
padding-bottom:.5em;
|
|
padding-left:1em;
|
|
}
|
|
|
|
.metrics-box {
|
|
font-size: 1.1em;
|
|
line-height: 130%;
|
|
}
|
|
|
|
.metrics-title {
|
|
font-size: 1.5em;
|
|
font-weight: 500;
|
|
margin-bottom: .25em;
|
|
}
|
|
|
|
.issue-description {
|
|
font-size: 1.3em;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.candidate-issues {
|
|
margin-left: 2em;
|
|
border-left: solid 1px; LightGray;
|
|
padding-left: 5%;
|
|
margin-top: .2em;
|
|
margin-bottom: .2em;
|
|
}
|
|
|
|
.issue-block {
|
|
border: 1px solid LightGray;
|
|
padding-left: .5em;
|
|
padding-top: .5em;
|
|
padding-bottom: .5em;
|
|
margin-bottom: .5em;
|
|
}
|
|
|
|
.issue-sev-high {
|
|
background-color: Pink;
|
|
}
|
|
|
|
.issue-sev-medium {
|
|
background-color: NavajoWhite;
|
|
}
|
|
|
|
.issue-sev-low {
|
|
background-color: LightCyan;
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="metrics">
|
|
<div class="metrics-box bordered-box">
|
|
<div class="metrics-title">
|
|
Metrics:<br>
|
|
</div>
|
|
Total lines of code: <span id="loc">1066</span><br>
|
|
Total lines skipped (#nosec): <span id="nosec">0</span>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<br>
|
|
<div id="results">
|
|
|
|
<div id="issue-0">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
|
|
<b>Test ID:</b> B101<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/kolors.py" target="_blank">/custom_nodes/BizyAir/kolors.py</a><br>
|
|
<b>Line number: </b>46<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
42 def encode(self, prompt, negative_prompt, num_images_per_prompt):
|
|
43 API_KEY = get_api_key()
|
|
44 split_pos_text = prompt.split("|")
|
|
45 num_prompts = len(split_pos_text)
|
|
46 assert (
|
|
47 num_prompts * num_images_per_prompt <= 4
|
|
48 ), f"The num_prompts*num_images_per_prompt should be less than or equal 4, got {num_prompts}x{num_images_per_prompt}={num_prompts*num_images_per_prompt}, try to reduce the '|' or num_images_per_prompt"
|
|
49
|
|
50 payload = {
|
|
51 "positive_prompt": prompt,
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-1">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
|
|
<b>Test ID:</b> B101<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/kolors.py" target="_blank">/custom_nodes/BizyAir/kolors.py</a><br>
|
|
<b>Line number: </b>226<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
222 "inputs": None,
|
|
223 "is_compress": True,
|
|
224 }
|
|
225 if latent is not None:
|
|
226 assert (
|
|
227 latent["samples"].shape[0] == kolors_embeds["prompt_embeds"].shape[0]
|
|
228 ), f"The batch size of latent samples should be the same as the prompt_embeds, got {latent['samples'].shape[0]} and {kolors_embeds['prompt_embeds'].shape[0]}"
|
|
229
|
|
230 # convert the tensors to numpy array
|
|
231 np_kolors_embeds = copy.deepcopy(kolors_embeds)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-2">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
|
|
<b>Test ID:</b> B101<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/supernode.py" target="_blank">/custom_nodes/BizyAir/supernode.py</a><br>
|
|
<b>Line number: </b>34<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
30 def super_resolution(self, image, scale="2x"):
|
|
31 API_KEY = get_api_key()
|
|
32 device = image.device
|
|
33 _, w, h, c = image.shape
|
|
34 assert (
|
|
35 w <= 512 and h <= 512
|
|
36 ), f"width and height must be less than 512, but got {w} and {h}"
|
|
37
|
|
38 # support RGB mode only now
|
|
39 image = image[:, :, :, :3]
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-3">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
|
|
<b>Test ID:</b> B101<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/supernode.py" target="_blank">/custom_nodes/BizyAir/supernode.py</a><br>
|
|
<b>Line number: </b>80<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
76 def remove_background(self, image):
|
|
77 API_KEY = get_api_key()
|
|
78 device = image.device
|
|
79 _, w, h, _ = image.shape
|
|
80 assert (
|
|
81 w <= 1024 and h <= 1024
|
|
82 ), f"width and height must be less than 1024, but got {w} and {h}"
|
|
83
|
|
84 payload = {
|
|
85 "is_compress": True,
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-4">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
|
|
<b>Test ID:</b> B101<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/supernode.py" target="_blank">/custom_nodes/BizyAir/supernode.py</a><br>
|
|
<b>Line number: </b>142<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
138 CATEGORY = "☁️BizyAir"
|
|
139
|
|
140 def generate_image(self, prompt, seed, width, height, cfg, batch_size):
|
|
141 API_KEY = get_api_key()
|
|
142 assert (
|
|
143 width <= 1024 and height <= 1024
|
|
144 ), f"width and height must be less than 1024, but got {width} and {height}"
|
|
145
|
|
146 payload = {
|
|
147 "batch_size": batch_size,
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-5">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Consider possible security implications associated with pickle module.<br>
|
|
<b>Test ID:</b> B403<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/502.html" target="_blank">CWE-502</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/utils.py" target="_blank">/custom_nodes/BizyAir/utils.py</a><br>
|
|
<b>Line number: </b>4<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b403-import-pickle" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b403-import-pickle</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
1 import base64
|
|
2 import json
|
|
3 import os
|
|
4 import pickle
|
|
5 import urllib.request
|
|
6 import urllib.parse
|
|
7 import zlib
|
|
8
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-6">
|
|
<div class="issue-block issue-sev-medium">
|
|
<b>blacklist: </b> Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.<br>
|
|
<b>Test ID:</b> B310<br>
|
|
<b>Severity: </b>MEDIUM<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/22.html" target="_blank">CWE-22</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/utils.py" target="_blank">/custom_nodes/BizyAir/utils.py</a><br>
|
|
<b>Line number: </b>27<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b310-urllib-urlopen</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
23 """
|
|
24 try:
|
|
25 data = json.dumps(payload).encode("utf-8")
|
|
26 req = urllib.request.Request(api_url, data=data, headers=headers, method="POST")
|
|
27 with urllib.request.urlopen(req) as response:
|
|
28 response_data = response.read().decode("utf-8")
|
|
29 return response_data
|
|
30 except urllib.error.URLError as e:
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-7">
|
|
<div class="issue-block issue-sev-medium">
|
|
<b>blacklist: </b> Pickle and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue.<br>
|
|
<b>Test ID:</b> B301<br>
|
|
<b>Severity: </b>MEDIUM<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/502.html" target="_blank">CWE-502</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/utils.py" target="_blank">/custom_nodes/BizyAir/utils.py</a><br>
|
|
<b>Line number: </b>94<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b301-pickle" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b301-pickle</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
90 print(
|
|
91 f"decode_and_deserialize: size of bytes is {format_bytes(len(tensor_bytes))}"
|
|
92 )
|
|
93
|
|
94 deserialized_object = pickle.loads(tensor_bytes)
|
|
95 return deserialized_object
|
|
96
|
|
97
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-8">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
|
|
<b>Test ID:</b> B101<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/utils.py" target="_blank">/custom_nodes/BizyAir/utils.py</a><br>
|
|
<b>Line number: </b>114<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
110 return f"{num_bytes / (1024 * 1024):.2f} MB"
|
|
111
|
|
112
|
|
113 def validate_api_key(key: str):
|
|
114 assert isinstance(key, str), f"API_KEY must be a string, got {type(key)}"
|
|
115 assert key.startswith(
|
|
116 "sk"
|
|
117 ), f"invalid key, please refer to https://cloud.siliconflow.cn to get your API_KEY, got {key}"
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-9">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>assert_used: </b> Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.<br>
|
|
<b>Test ID:</b> B101<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/703.html" target="_blank">CWE-703</a><br>
|
|
<b>File: </b><a href="/custom_nodes/BizyAir/utils.py" target="_blank">/custom_nodes/BizyAir/utils.py</a><br>
|
|
<b>Line number: </b>115<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b101_assert_used.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
111
|
|
112
|
|
113 def validate_api_key(key: str):
|
|
114 assert isinstance(key, str), f"API_KEY must be a string, got {type(key)}"
|
|
115 assert key.startswith(
|
|
116 "sk"
|
|
117 ), f"invalid key, please refer to https://cloud.siliconflow.cn to get your API_KEY, got {key}"
|
|
118
|
|
119
|
|
120 def get_api_key():
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|