Showing 195 of 515 total issues
File zap_scanner_active.py
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python
# SPDX-FileCopyrightText: the secureCodeBox authors
#
# SPDX-License-Identifier: Apache-2.0
Function parse
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function parse(niktoReport) {
if (!niktoReport) return [];
return niktoReport.flatMap(
({host, ip, port: portString, banner, vulnerabilities}) => {
Function templateCascadingRule
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function templateCascadingRule(
parentScan: Scan,
finding: Finding,
cascadingRule: CascadingRule
): CascadingRule {
Function parseResultFile
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function parseResultFile(fileContent) {
let targetList = [];
for(const rawTarget of fileContent) {
if (Object.keys(rawTarget).length > 0) { //Check for empty target
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method createEngagement
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Engagement createEngagement(Scan scan, Long productId, Long userId) throws URISyntaxException, JsonProcessingException {
String engagementName = this.getEngagementsName(scan);
List<String> tags = scan.getEngagementTags().orElseGet(List::of);
String version = scan.getEngagementVersion().orElse("");
Function transformToFindings
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function transformToFindings(hosts) {
const scriptFindings = transformNMAPScripts(hosts);
const portFindings = hosts.flatMap(({ openPorts = [], ...hostInfo }) => {
Function parse
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function parse(fileContent) {
return fileContent.results.flatMap((result) => {
// Assemble location as path to file and line range
const location =
result.path + ":" + result.start.line + "-" + result.end.line;
Function updateFindings
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function updateFindings(findings) {
const findingsUploadUrl = process.argv[5];
if (findingsUploadUrl === undefined) {
console.error(
"Tried to upload Findings but didn't find a valid URL to upload the findings to."
Function categorize
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function categorize({id}) {
if (id === 999957) {
return ["X-Frame-Options Header", LOW];
} else if (id === 999102) {
return ["X-XSS-Protection", LOW];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function operatorInCIDR
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function operatorInCIDR({
scopeAnnotationValue,
findingValues,
}: Operands): boolean {
function getIPv4Or6(ipValue: string): Address4 | Address6 {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function main
has 68 lines of code (exceeds 50 allowed). Consider refactoring. Open
func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
Function convertTrivyK8sFindingToSCBFinding
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function convertTrivyK8sFindingToSCBFinding(trivyK8sFinding, clusterName, namespace, kind, k8sName, target, clazz, type, categoryName) {
let references = trivyK8sFinding.PrimaryURL ? [{type: "URL", value: trivyK8sFinding.PrimaryURL}] : [];
const url_references = getUrlReferences(trivyK8sFinding.References).filter(ref => ref.value !== trivyK8sFinding.PrimaryURL);
references = references.concat(url_references);
Function main
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function main() {
console.log("Starting Parser");
let scan = await extractScan();
let parseDefinition = await extractParseDefinition(scan);
const resultFileUrl = process.argv[2];
Function parse
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function parse(fileContent) {
return fileContent
.split("\n")
.filter(Boolean)
.filter((line) => line && line.startsWith("{") && line.endsWith("}"))
Method ScanSpec.DeepCopyInto
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (in *ScanSpec) DeepCopyInto(out *ScanSpec) {
*out = *in
if in.ResourceMode != nil {
in, out := &in.ResourceMode, &out.ResourceMode
*out = new(ResourceMode)
Function parse
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function parse(fileContent) {
const host = fileContent;
if (typeof host === "string") return [];
const destination = host.target.split(":");
Consider simplifying this complex logical expression. Open
if port.Port == 80 ||
port.Port == 8080 ||
port.Port == 443 ||
port.Port == 8443 ||
// Node.js
Function createDocFilesFromMainRepository
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function createDocFilesFromMainRepository(relPath, targetPath, dirNames) {
for (const dirName of dirNames) {
const readMe = `${relPath}/${dirName}/README.md`;
if (!fs.existsSync(readMe)) {
Function updateScanStatus
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function updateScanStatus(findings) {
try {
const findingCategories = new Map();
for (const { category } of findings) {
if (findingCategories.has(category)) {
Function createExampleScan
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createExampleScan(): Scan {
return {
metadata: {
uid: "09988cdf-1fc7-4f85-95ee-1b1d65dbc7cc",
name: "demo-scan-1601086432",