mirror of
https://github.com/hanzoui/custom-nodes-security-scan.git
synced 2026-10-30 20:56:54 +00:00
1539 lines
62 KiB
HTML
1539 lines
62 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">8163</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/facerestore_cf/basicsr/archs/arch_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/archs/arch_util.py</a><br>
|
|
<b>Line number: </b>133<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>
|
|
129
|
|
130 Returns:
|
|
131 Tensor: Warped image or feature map.
|
|
132 """
|
|
133 assert x.size()[-2:] == flow.size()[1:3]
|
|
134 _, _, h, w = x.size()
|
|
135 # create mesh grid
|
|
136 grid_y, grid_x = torch.meshgrid(torch.arange(0, h).type_as(x), torch.arange(0, w).type_as(x))
|
|
</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/facerestore_cf/basicsr/archs/arch_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/archs/arch_util.py</a><br>
|
|
<b>Line number: </b>202<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>
|
|
198 Tensor: the pixel unshuffled feature.
|
|
199 """
|
|
200 b, c, hh, hw = x.size()
|
|
201 out_channel = c * (scale**2)
|
|
202 assert hh % scale == 0 and hw % scale == 0
|
|
203 h = hh // scale
|
|
204 w = hw // scale
|
|
205 x_view = x.view(b, c, h, scale, w, scale)
|
|
</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/facerestore_cf/basicsr/archs/codeformer_arch.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/archs/codeformer_arch.py</a><br>
|
|
<b>Line number: </b>21<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>
|
|
17 eps (float): A small value added to the variance to avoid
|
|
18 divide-by-zero. Default: 1e-5.
|
|
19 """
|
|
20 size = feat.size()
|
|
21 assert len(size) == 4, 'The input feature should be 4D tensor.'
|
|
22 b, c = size[:2]
|
|
23 feat_var = feat.view(b, c, -1).var(dim=2) + eps
|
|
24 feat_std = feat_var.sqrt().view(b, c, 1, 1)
|
|
</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/facerestore_cf/basicsr/data/data_sampler.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_sampler.py</a><br>
|
|
<b>Line number: </b>40<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>
|
|
36 indices = [v % dataset_size for v in indices]
|
|
37
|
|
38 # subsample
|
|
39 indices = indices[self.rank:self.total_size:self.num_replicas]
|
|
40 assert len(indices) == self.num_samples
|
|
41
|
|
42 return iter(indices)
|
|
43
|
|
</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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>55<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>
|
|
51
|
|
52 Returns:
|
|
53 list[int]: A list of indices.
|
|
54 """
|
|
55 assert num_frames % 2 == 1, 'num_frames should be an odd number.'
|
|
56 assert padding in ('replicate', 'reflection', 'reflection_circle', 'circle'), f'Wrong padding mode: {padding}.'
|
|
57
|
|
58 max_frame_num = max_frame_num - 1 # start from 0
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-5">
|
|
<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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>56<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>
|
|
52 Returns:
|
|
53 list[int]: A list of indices.
|
|
54 """
|
|
55 assert num_frames % 2 == 1, 'num_frames should be an odd number.'
|
|
56 assert padding in ('replicate', 'reflection', 'reflection_circle', 'circle'), f'Wrong padding mode: {padding}.'
|
|
57
|
|
58 max_frame_num = max_frame_num - 1 # start from 0
|
|
59 num_pad = num_frames // 2
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-6">
|
|
<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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>122<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>
|
|
118
|
|
119 Returns:
|
|
120 list[str]: Returned path list.
|
|
121 """
|
|
122 assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
|
|
123 f'But got {len(folders)}')
|
|
124 assert len(keys) == 2, ('The len of keys should be 2 with [input_key, gt_key]. ' f'But got {len(keys)}')
|
|
125 input_folder, gt_folder = folders
|
|
126 input_key, gt_key = keys
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-7">
|
|
<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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>124<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>
|
|
120 list[str]: Returned path list.
|
|
121 """
|
|
122 assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
|
|
123 f'But got {len(folders)}')
|
|
124 assert len(keys) == 2, ('The len of keys should be 2 with [input_key, gt_key]. ' f'But got {len(keys)}')
|
|
125 input_folder, gt_folder = folders
|
|
126 input_key, gt_key = keys
|
|
127
|
|
</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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>171<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>
|
|
167
|
|
168 Returns:
|
|
169 list[str]: Returned path list.
|
|
170 """
|
|
171 assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
|
|
172 f'But got {len(folders)}')
|
|
173 assert len(keys) == 2, ('The len of keys should be 2 with [input_key, gt_key]. ' f'But got {len(keys)}')
|
|
174 input_folder, gt_folder = folders
|
|
175 input_key, gt_key = keys
|
|
</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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>173<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>
|
|
169 list[str]: Returned path list.
|
|
170 """
|
|
171 assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
|
|
172 f'But got {len(folders)}')
|
|
173 assert len(keys) == 2, ('The len of keys should be 2 with [input_key, gt_key]. ' f'But got {len(keys)}')
|
|
174 input_folder, gt_folder = folders
|
|
175 input_key, gt_key = keys
|
|
176
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-10">
|
|
<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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>205<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>
|
|
201
|
|
202 Returns:
|
|
203 list[str]: Returned path list.
|
|
204 """
|
|
205 assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
|
|
206 f'But got {len(folders)}')
|
|
207 assert len(keys) == 2, ('The len of keys should be 2 with [input_key, gt_key]. ' f'But got {len(keys)}')
|
|
208 input_folder, gt_folder = folders
|
|
209 input_key, gt_key = keys
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-11">
|
|
<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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>207<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>
|
|
203 list[str]: Returned path list.
|
|
204 """
|
|
205 assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
|
|
206 f'But got {len(folders)}')
|
|
207 assert len(keys) == 2, ('The len of keys should be 2 with [input_key, gt_key]. ' f'But got {len(keys)}')
|
|
208 input_folder, gt_folder = folders
|
|
209 input_key, gt_key = keys
|
|
210
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-12">
|
|
<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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>213<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>
|
|
209 input_key, gt_key = keys
|
|
210
|
|
211 input_paths = list(scandir(input_folder))
|
|
212 gt_paths = list(scandir(gt_folder))
|
|
213 assert len(input_paths) == len(gt_paths), (f'{input_key} and {gt_key} datasets have different number of images: '
|
|
214 f'{len(input_paths)}, {len(gt_paths)}.')
|
|
215 paths = []
|
|
216 for gt_path in gt_paths:
|
|
217 basename, ext = osp.splitext(osp.basename(gt_path))
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-13">
|
|
<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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>220<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>
|
|
216 for gt_path in gt_paths:
|
|
217 basename, ext = osp.splitext(osp.basename(gt_path))
|
|
218 input_name = f'{filename_tmpl.format(basename)}{ext}'
|
|
219 input_path = osp.join(input_folder, input_name)
|
|
220 assert input_name in input_paths, (f'{input_name} is not in ' f'{input_key}_paths.')
|
|
221 gt_path = osp.join(gt_folder, gt_path)
|
|
222 paths.append(dict([(f'{input_key}_path', input_path), (f'{gt_key}_path', gt_path)]))
|
|
223 return paths
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-14">
|
|
<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/facerestore_cf/basicsr/data/data_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/data_util.py</a><br>
|
|
<b>Line number: </b>287<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>
|
|
283
|
|
284 Returns:
|
|
285 Tensor: DUF downsampled frames.
|
|
286 """
|
|
287 assert scale in (2, 3, 4), f'Only support scale (2, 3, 4), but got {scale}.'
|
|
288
|
|
289 squeeze_flag = False
|
|
290 if x.ndim == 4:
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-15">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
|
|
<b>Test ID:</b> B311<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/data/transforms.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/transforms.py</a><br>
|
|
<b>Line number: </b>64<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
60 f'({lq_patch_size}, {lq_patch_size}). '
|
|
61 f'Please remove {gt_path}.')
|
|
62
|
|
63 # randomly choose top and left coordinates for lq patch
|
|
64 top = random.randint(0, h_lq - lq_patch_size)
|
|
65 left = random.randint(0, w_lq - lq_patch_size)
|
|
66
|
|
67 # crop lq patch
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-16">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
|
|
<b>Test ID:</b> B311<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/data/transforms.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/transforms.py</a><br>
|
|
<b>Line number: </b>65<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
61 f'Please remove {gt_path}.')
|
|
62
|
|
63 # randomly choose top and left coordinates for lq patch
|
|
64 top = random.randint(0, h_lq - lq_patch_size)
|
|
65 left = random.randint(0, w_lq - lq_patch_size)
|
|
66
|
|
67 # crop lq patch
|
|
68 img_lqs = [v[top:top + lq_patch_size, left:left + lq_patch_size, ...] for v in img_lqs]
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-17">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
|
|
<b>Test ID:</b> B311<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/data/transforms.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/transforms.py</a><br>
|
|
<b>Line number: </b>102<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
98 list[ndarray] | ndarray: Augmented images and flows. If returned
|
|
99 results only have one element, just return ndarray.
|
|
100
|
|
101 """
|
|
102 hflip = hflip and random.random() < 0.5
|
|
103 vflip = rotation and random.random() < 0.5
|
|
104 rot90 = rotation and random.random() < 0.5
|
|
105
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-18">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
|
|
<b>Test ID:</b> B311<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/data/transforms.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/transforms.py</a><br>
|
|
<b>Line number: </b>103<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
99 results only have one element, just return ndarray.
|
|
100
|
|
101 """
|
|
102 hflip = hflip and random.random() < 0.5
|
|
103 vflip = rotation and random.random() < 0.5
|
|
104 rot90 = rotation and random.random() < 0.5
|
|
105
|
|
106 def _augment(img):
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-19">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
|
|
<b>Test ID:</b> B311<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/data/transforms.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/data/transforms.py</a><br>
|
|
<b>Line number: </b>104<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
100
|
|
101 """
|
|
102 hflip = hflip and random.random() < 0.5
|
|
103 vflip = rotation and random.random() < 0.5
|
|
104 rot90 = rotation and random.random() < 0.5
|
|
105
|
|
106 def _augment(img):
|
|
107 if hflip: # horizontal
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-20">
|
|
<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/facerestore_cf/basicsr/losses/loss_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/losses/loss_util.py</a><br>
|
|
<b>Line number: </b>39<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>
|
|
35 Tensor: Loss values.
|
|
36 """
|
|
37 # if weight is specified, apply element-wise weight
|
|
38 if weight is not None:
|
|
39 assert weight.dim() == loss.dim()
|
|
40 assert weight.size(1) == 1 or weight.size(1) == loss.size(1)
|
|
41 loss = loss * weight
|
|
42
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-21">
|
|
<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/facerestore_cf/basicsr/losses/loss_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/losses/loss_util.py</a><br>
|
|
<b>Line number: </b>40<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>
|
|
36 """
|
|
37 # if weight is specified, apply element-wise weight
|
|
38 if weight is not None:
|
|
39 assert weight.dim() == loss.dim()
|
|
40 assert weight.size(1) == 1 or weight.size(1) == loss.size(1)
|
|
41 loss = loss * weight
|
|
42
|
|
43 # if weight is not specified or reduction is sum, just reduce the loss
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-22">
|
|
<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/facerestore_cf/basicsr/metrics/psnr_ssim.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/metrics/psnr_ssim.py</a><br>
|
|
<b>Line number: </b>27<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>
|
|
23 Returns:
|
|
24 float: psnr result.
|
|
25 """
|
|
26
|
|
27 assert img1.shape == img2.shape, (f'Image shapes are differnet: {img1.shape}, {img2.shape}.')
|
|
28 if input_order not in ['HWC', 'CHW']:
|
|
29 raise ValueError(f'Wrong input_order {input_order}. Supported input_orders are ' '"HWC" and "CHW"')
|
|
30 img1 = reorder_image(img1, input_order=input_order)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-23">
|
|
<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/facerestore_cf/basicsr/metrics/psnr_ssim.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/metrics/psnr_ssim.py</a><br>
|
|
<b>Line number: </b>109<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>
|
|
105 Returns:
|
|
106 float: ssim result.
|
|
107 """
|
|
108
|
|
109 assert img1.shape == img2.shape, (f'Image shapes are differnet: {img1.shape}, {img2.shape}.')
|
|
110 if input_order not in ['HWC', 'CHW']:
|
|
111 raise ValueError(f'Wrong input_order {input_order}. Supported input_orders are ' '"HWC" and "CHW"')
|
|
112 img1 = reorder_image(img1, input_order=input_order)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-24">
|
|
<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/facerestore_cf/basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/ops/dcn/deform_conv.py</a><br>
|
|
<b>Line number: </b>59<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>
|
|
55 if not input.is_cuda:
|
|
56 raise NotImplementedError
|
|
57 else:
|
|
58 cur_im2col_step = min(ctx.im2col_step, input.shape[0])
|
|
59 assert (input.shape[0] % cur_im2col_step) == 0, 'im2col step must divide batchsize'
|
|
60 deform_conv_ext.deform_conv_forward(input, weight,
|
|
61 offset, output, ctx.bufs_[0], ctx.bufs_[1], weight.size(3),
|
|
62 weight.size(2), ctx.stride[1], ctx.stride[0], ctx.padding[1],
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-25">
|
|
<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/facerestore_cf/basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/ops/dcn/deform_conv.py</a><br>
|
|
<b>Line number: </b>78<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>
|
|
74 if not grad_output.is_cuda:
|
|
75 raise NotImplementedError
|
|
76 else:
|
|
77 cur_im2col_step = min(ctx.im2col_step, input.shape[0])
|
|
78 assert (input.shape[0] % cur_im2col_step) == 0, 'im2col step must divide batchsize'
|
|
79
|
|
80 if ctx.needs_input_grad[0] or ctx.needs_input_grad[1]:
|
|
81 grad_input = torch.zeros_like(input)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-26">
|
|
<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/facerestore_cf/basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/ops/dcn/deform_conv.py</a><br>
|
|
<b>Line number: </b>200<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>
|
|
196 deformable_groups=1,
|
|
197 bias=False):
|
|
198 super(DeformConv, self).__init__()
|
|
199
|
|
200 assert not bias
|
|
201 assert in_channels % groups == 0, \
|
|
202 f'in_channels {in_channels} is not divisible by groups {groups}'
|
|
203 assert out_channels % groups == 0, \
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-27">
|
|
<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/facerestore_cf/basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/ops/dcn/deform_conv.py</a><br>
|
|
<b>Line number: </b>201<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>
|
|
197 bias=False):
|
|
198 super(DeformConv, self).__init__()
|
|
199
|
|
200 assert not bias
|
|
201 assert in_channels % groups == 0, \
|
|
202 f'in_channels {in_channels} is not divisible by groups {groups}'
|
|
203 assert out_channels % groups == 0, \
|
|
204 f'out_channels {out_channels} is not divisible ' \
|
|
205 f'by groups {groups}'
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-28">
|
|
<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/facerestore_cf/basicsr/ops/dcn/deform_conv.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/ops/dcn/deform_conv.py</a><br>
|
|
<b>Line number: </b>203<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>
|
|
199
|
|
200 assert not bias
|
|
201 assert in_channels % groups == 0, \
|
|
202 f'in_channels {in_channels} is not divisible by groups {groups}'
|
|
203 assert out_channels % groups == 0, \
|
|
204 f'out_channels {out_channels} is not divisible ' \
|
|
205 f'by groups {groups}'
|
|
206
|
|
207 self.in_channels = in_channels
|
|
208 self.out_channels = out_channels
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-29">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Consider possible security implications associated with the subprocess module.<br>
|
|
<b>Test ID:</b> B404<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/setup.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/setup.py</a><br>
|
|
<b>Line number: </b>6<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b404-import-subprocess" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b404-import-subprocess</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
2
|
|
3 from setuptools import find_packages, setup
|
|
4
|
|
5 import os
|
|
6 import subprocess
|
|
7 import sys
|
|
8 import time
|
|
9 import torch
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-30">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>subprocess_without_shell_equals_true: </b> subprocess call - check for execution of untrusted input.<br>
|
|
<b>Test ID:</b> B603<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/setup.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/setup.py</a><br>
|
|
<b>Line number: </b>34<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b603_subprocess_without_shell_equals_true.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b603_subprocess_without_shell_equals_true.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
30 # LANGUAGE is used on win32
|
|
31 env['LANGUAGE'] = 'C'
|
|
32 env['LANG'] = 'C'
|
|
33 env['LC_ALL'] = 'C'
|
|
34 out = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
|
|
35 return out
|
|
36
|
|
37 try:
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-31">
|
|
<div class="issue-block issue-sev-medium">
|
|
<b>exec_used: </b> Use of exec detected.<br>
|
|
<b>Test ID:</b> B102<br>
|
|
<b>Severity: </b>MEDIUM<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/setup.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/setup.py</a><br>
|
|
<b>Line number: </b>80<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b102_exec_used.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b102_exec_used.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
76
|
|
77
|
|
78 def get_version():
|
|
79 with open(version_file, 'r') as f:
|
|
80 exec(compile(f.read(), version_file, 'exec'))
|
|
81 return locals()['__version__']
|
|
82
|
|
83
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-32">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Standard pseudo-random generators are not suitable for security/cryptographic purposes.<br>
|
|
<b>Test ID:</b> B311<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/330.html" target="_blank">CWE-330</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/train.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/train.py</a><br>
|
|
<b>Line number: </b>48<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b311-random</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
44
|
|
45 # random seed
|
|
46 seed = opt.get('manual_seed')
|
|
47 if seed is None:
|
|
48 seed = random.randint(1, 10000)
|
|
49 opt['manual_seed'] = seed
|
|
50 set_random_seed(seed + opt['rank'])
|
|
51
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-33">
|
|
<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/facerestore_cf/basicsr/train.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/train.py</a><br>
|
|
<b>Line number: </b>63<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>
|
|
59 logger.info(dict2str(opt))
|
|
60
|
|
61 # initialize wandb logger before tensorboard logger to allow proper sync:
|
|
62 if (opt['logger'].get('wandb') is not None) and (opt['logger']['wandb'].get('project') is not None):
|
|
63 assert opt['logger'].get('use_tb_logger') is True, ('should turn on tensorboard when using wandb')
|
|
64 init_wandb_logger(opt)
|
|
65 tb_logger = None
|
|
66 if opt['logger'].get('use_tb_logger'):
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-34">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>blacklist: </b> Consider possible security implications associated with the subprocess module.<br>
|
|
<b>Test ID:</b> B404<br>
|
|
<b>Severity: </b>LOW<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/utils/dist_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/utils/dist_util.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#b404-import-subprocess" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_imports.html#b404-import-subprocess</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
1 # Modified from https://github.com/open-mmlab/mmcv/blob/master/mmcv/runner/dist_utils.py # noqa: E501
|
|
2 import functools
|
|
3 import os
|
|
4 import subprocess
|
|
5 import torch
|
|
6 import torch.distributed as dist
|
|
7 import torch.multiprocessing as mp
|
|
8
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-35">
|
|
<div class="issue-block issue-sev-high">
|
|
<b>start_process_with_a_shell: </b> Starting a process with a shell, possible injection detected, security issue.<br>
|
|
<b>Test ID:</b> B605<br>
|
|
<b>Severity: </b>HIGH<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/utils/dist_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/utils/dist_util.py</a><br>
|
|
<b>Line number: </b>44<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b605_start_process_with_a_shell.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b605_start_process_with_a_shell.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
40 ntasks = int(os.environ['SLURM_NTASKS'])
|
|
41 node_list = os.environ['SLURM_NODELIST']
|
|
42 num_gpus = torch.cuda.device_count()
|
|
43 torch.cuda.set_device(proc_id % num_gpus)
|
|
44 addr = subprocess.getoutput(f'scontrol show hostname {node_list} | head -n1')
|
|
45 # specify master port
|
|
46 if port is not None:
|
|
47 os.environ['MASTER_PORT'] = str(port)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-36">
|
|
<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/facerestore_cf/basicsr/utils/file_client.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/utils/file_client.py</a><br>
|
|
<b>Line number: </b>107<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>
|
|
103 if isinstance(db_paths, list):
|
|
104 self.db_paths = [str(v) for v in db_paths]
|
|
105 elif isinstance(db_paths, str):
|
|
106 self.db_paths = [str(db_paths)]
|
|
107 assert len(client_keys) == len(self.db_paths), ('client_keys and db_paths should have the same length, '
|
|
108 f'but received {len(client_keys)} and {len(self.db_paths)}.')
|
|
109
|
|
110 self._client = {}
|
|
111 for client, path in zip(client_keys, self.db_paths):
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-37">
|
|
<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/facerestore_cf/basicsr/utils/file_client.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/utils/file_client.py</a><br>
|
|
<b>Line number: </b>122<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>
|
|
118 filepath (str | obj:`Path`): Here, filepath is the lmdb key.
|
|
119 client_key (str): Used for distinguishing differnet lmdb envs.
|
|
120 """
|
|
121 filepath = str(filepath)
|
|
122 assert client_key in self._client, (f'client_key {client_key} is not ' 'in lmdb clients.')
|
|
123 client = self._client[client_key]
|
|
124 with client.begin(write=False) as txn:
|
|
125 value_buf = txn.get(filepath.encode('ascii'))
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-38">
|
|
<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/facerestore_cf/basicsr/utils/lmdb_util.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/utils/lmdb_util.py</a><br>
|
|
<b>Line number: </b>61<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>
|
|
57 map_size (int | None): Map size for lmdb env. If None, use the
|
|
58 estimated size from images. Default: None
|
|
59 """
|
|
60
|
|
61 assert len(img_path_list) == len(keys), ('img_path_list and keys should have the same length, '
|
|
62 f'but got {len(img_path_list)} and {len(keys)}')
|
|
63 print(f'Create lmdb for {data_path}, save to {lmdb_path}...')
|
|
64 print(f'Totoal images: {len(img_path_list)}')
|
|
65 if not lmdb_path.endswith('.lmdb'):
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-39">
|
|
<div class="issue-block issue-sev-medium">
|
|
<b>yaml_load: </b> Use of unsafe yaml load. Allows instantiation of arbitrary objects. Consider yaml.safe_load().<br>
|
|
<b>Test ID:</b> B506<br>
|
|
<b>Severity: </b>MEDIUM<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/20.html" target="_blank">CWE-20</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/basicsr/utils/options.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/utils/options.py</a><br>
|
|
<b>Line number: </b>44<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b506_yaml_load.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b506_yaml_load.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
40 (dict): Options.
|
|
41 """
|
|
42 with open(opt_path, mode='r') as f:
|
|
43 Loader, _ = ordered_yaml()
|
|
44 opt = yaml.load(f, Loader=Loader)
|
|
45
|
|
46 opt['is_train'] = is_train
|
|
47
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-40">
|
|
<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/facerestore_cf/basicsr/utils/registry.py" target="_blank">/custom_nodes/facerestore_cf/basicsr/utils/registry.py</a><br>
|
|
<b>Line number: </b>39<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>
|
|
35 self._name = name
|
|
36 self._obj_map = {}
|
|
37
|
|
38 def _do_register(self, name, obj):
|
|
39 assert (name not in self._obj_map), (f"An object named '{name}' was already registered "
|
|
40 f"in '{self._name}' registry!")
|
|
41 self._obj_map[name] = obj
|
|
42
|
|
43 def register(self, obj=None):
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-41">
|
|
<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/facerestore_cf/codeformer_arch.py" target="_blank">/custom_nodes/facerestore_cf/codeformer_arch.py</a><br>
|
|
<b>Line number: </b>21<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>
|
|
17 eps (float): A small value added to the variance to avoid
|
|
18 divide-by-zero. Default: 1e-5.
|
|
19 """
|
|
20 size = feat.size()
|
|
21 assert len(size) == 4, 'The input feature should be 4D tensor.'
|
|
22 b, c = size[:2]
|
|
23 feat_var = feat.view(b, c, -1).var(dim=2) + eps
|
|
24 feat_std = feat_var.sqrt().view(b, c, 1, 1)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-42">
|
|
<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/facerestore_cf/facelib/detection/retinaface/retinaface_net.py" target="_blank">/custom_nodes/facerestore_cf/facelib/detection/retinaface/retinaface_net.py</a><br>
|
|
<b>Line number: </b>40<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>
|
|
36 class SSH(nn.Module):
|
|
37
|
|
38 def __init__(self, in_channel, out_channel):
|
|
39 super(SSH, self).__init__()
|
|
40 assert out_channel % 4 == 0
|
|
41 leaky = 0
|
|
42 if (out_channel <= 64):
|
|
43 leaky = 0.1
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-43">
|
|
<div class="issue-block issue-sev-medium">
|
|
<b>blacklist: </b> Use of possibly insecure function - consider using safer ast.literal_eval.<br>
|
|
<b>Test ID:</b> B307<br>
|
|
<b>Severity: </b>MEDIUM<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/facelib/detection/yolov5face/models/yolo.py" target="_blank">/custom_nodes/facerestore_cf/facelib/detection/yolov5face/models/yolo.py</a><br>
|
|
<b>Line number: </b>188<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
184 no = na * (nc + 5) # number of outputs = anchors * (classes + 5)
|
|
185
|
|
186 layers, save, c2 = [], [], ch[-1] # layers, savelist, ch out
|
|
187 for i, (f, n, m, args) in enumerate(d["backbone"] + d["head"]): # from, number, module, args
|
|
188 m = eval(m) if isinstance(m, str) else m # eval strings
|
|
189 for j, a in enumerate(args):
|
|
190 try:
|
|
191 args[j] = eval(a) if isinstance(a, str) else a # eval strings
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-44">
|
|
<div class="issue-block issue-sev-medium">
|
|
<b>blacklist: </b> Use of possibly insecure function - consider using safer ast.literal_eval.<br>
|
|
<b>Test ID:</b> B307<br>
|
|
<b>Severity: </b>MEDIUM<br>
|
|
<b>Confidence: </b>HIGH<br>
|
|
<b>CWE: </b><a href="https://cwe.mitre.org/data/definitions/78.html" target="_blank">CWE-78</a><br>
|
|
<b>File: </b><a href="/custom_nodes/facerestore_cf/facelib/detection/yolov5face/models/yolo.py" target="_blank">/custom_nodes/facerestore_cf/facelib/detection/yolov5face/models/yolo.py</a><br>
|
|
<b>Line number: </b>191<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval" target="_blank">https://bandit.readthedocs.io/en/1.7.9/blacklists/blacklist_calls.html#b307-eval</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
187 for i, (f, n, m, args) in enumerate(d["backbone"] + d["head"]): # from, number, module, args
|
|
188 m = eval(m) if isinstance(m, str) else m # eval strings
|
|
189 for j, a in enumerate(args):
|
|
190 try:
|
|
191 args[j] = eval(a) if isinstance(a, str) else a # eval strings
|
|
192 except:
|
|
193 pass
|
|
194
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-45">
|
|
<div class="issue-block issue-sev-low">
|
|
<b>try_except_pass: </b> Try, Except, Pass detected.<br>
|
|
<b>Test ID:</b> B110<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/facerestore_cf/facelib/detection/yolov5face/models/yolo.py" target="_blank">/custom_nodes/facerestore_cf/facelib/detection/yolov5face/models/yolo.py</a><br>
|
|
<b>Line number: </b>192<br>
|
|
<b>More info: </b><a href="https://bandit.readthedocs.io/en/1.7.9/plugins/b110_try_except_pass.html" target="_blank">https://bandit.readthedocs.io/en/1.7.9/plugins/b110_try_except_pass.html</a><br>
|
|
|
|
<div class="code">
|
|
<pre>
|
|
188 m = eval(m) if isinstance(m, str) else m # eval strings
|
|
189 for j, a in enumerate(args):
|
|
190 try:
|
|
191 args[j] = eval(a) if isinstance(a, str) else a # eval strings
|
|
192 except:
|
|
193 pass
|
|
194
|
|
195 n = max(round(n * gd), 1) if n > 1 else n # depth gain
|
|
196 if m in [
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-46">
|
|
<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/facerestore_cf/facelib/parsing/parsenet.py" target="_blank">/custom_nodes/facerestore_cf/facelib/parsing/parsenet.py</a><br>
|
|
<b>Line number: </b>33<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>
|
|
29 self.norm = nn.LayerNorm(normalize_shape)
|
|
30 elif norm_type == 'none':
|
|
31 self.norm = lambda x: x * 1.0
|
|
32 else:
|
|
33 assert 1 == 0, f'Norm type {norm_type} not support.'
|
|
34
|
|
35 def forward(self, x, ref=None):
|
|
36 if self.norm_type == 'spade':
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-47">
|
|
<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/facerestore_cf/facelib/parsing/parsenet.py" target="_blank">/custom_nodes/facerestore_cf/facelib/parsing/parsenet.py</a><br>
|
|
<b>Line number: </b>68<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>
|
|
64 self.func = nn.SELU(True)
|
|
65 elif relu_type == 'none':
|
|
66 self.func = lambda x: x * 1.0
|
|
67 else:
|
|
68 assert 1 == 0, f'Relu type {relu_type} not support.'
|
|
69
|
|
70 def forward(self, x):
|
|
71 return self.func(x)
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-48">
|
|
<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/facerestore_cf/facelib/utils/face_restoration_helper.py" target="_blank">/custom_nodes/facerestore_cf/facelib/utils/face_restoration_helper.py</a><br>
|
|
<b>Line number: </b>65<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>
|
|
61 self.template_3points = template_3points # improve robustness
|
|
62 self.upscale_factor = upscale_factor
|
|
63 # the cropped face ratio based on the square face
|
|
64 self.crop_ratio = crop_ratio # (h, w)
|
|
65 assert (self.crop_ratio[0] >= 1 and self.crop_ratio[1] >= 1), 'crop ration only supports >=1'
|
|
66 self.face_size = (int(face_size * self.crop_ratio[1]), int(face_size * self.crop_ratio[0]))
|
|
67
|
|
68 if self.template_3points:
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-49">
|
|
<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/facerestore_cf/facelib/utils/face_restoration_helper.py" target="_blank">/custom_nodes/facerestore_cf/facelib/utils/face_restoration_helper.py</a><br>
|
|
<b>Line number: </b>257<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>
|
|
253 def align_warp_face(self, save_cropped_path=None, border_mode='constant'):
|
|
254 """Align and warp faces with face template.
|
|
255 """
|
|
256 if self.pad_blur:
|
|
257 assert len(self.pad_input_imgs) == len(
|
|
258 self.all_landmarks_5), f'Mismatched samples: {len(self.pad_input_imgs)} and {len(self.all_landmarks_5)}'
|
|
259 for idx, landmark in enumerate(self.all_landmarks_5):
|
|
260 # use 5 landmarks to get affine matrix
|
|
261 # use cv2.LMEDS method for the equivalence to skimage transform
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="issue-50">
|
|
<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/facerestore_cf/facelib/utils/face_restoration_helper.py" target="_blank">/custom_nodes/facerestore_cf/facelib/utils/face_restoration_helper.py</a><br>
|
|
<b>Line number: </b>313<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>
|
|
309 upsample_img = cv2.resize(self.input_img, (w_up, h_up), interpolation=cv2.INTER_LINEAR)
|
|
310 else:
|
|
311 upsample_img = cv2.resize(upsample_img, (w_up, h_up), interpolation=cv2.INTER_LANCZOS4)
|
|
312
|
|
313 assert len(self.restored_faces) == len(
|
|
314 self.inverse_affine_matrices), ('length of restored_faces and affine_matrices are different.')
|
|
315
|
|
316 inv_mask_borders = []
|
|
317 for restored_face, inverse_affine in zip(self.restored_faces, self.inverse_affine_matrices):
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|