secureCodeBox/secureCodeBox

View on GitHub

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
Severity: Minor
Found in scanners/zap-advanced/scanner/zapclient/scanner/zap_scanner_active.py - About 2 hrs to fix

    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}) => {
    Severity: Minor
    Found in scanners/nikto/parser/parser.js - About 1 hr to fix

      Function templateCascadingRule has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function templateCascadingRule(
        parentScan: Scan,
        finding: Finding,
        cascadingRule: CascadingRule
      ): CascadingRule {
      Severity: Minor
      Found in hooks/cascading-scans/hook/hook.ts - About 1 hr to fix

        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
        Severity: Minor
        Found in scanners/whatweb/parser/parser.js - About 1 hr to fix

        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 }) => {
          Severity: Minor
          Found in scanners/nmap/parser/parser.js - About 1 hr to fix

            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;
            Severity: Minor
            Found in scanners/semgrep/parser/parser.js - About 1 hr to fix

              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."
              Severity: Minor
              Found in hook-sdk/nodejs/hook-wrapper.js - About 1 hr to fix

                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];
                Severity: Minor
                Found in scanners/nikto/parser/parser.js - About 1 hr to fix

                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 {
                Severity: Minor
                Found in hooks/cascading-scans/hook/scope-limiter.ts - About 1 hr to fix

                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.")
                Severity: Minor
                Found in operator/main.go - About 1 hr to fix

                  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);
                  Severity: Minor
                  Found in scanners/trivy/parser/parser.js - About 1 hr to fix

                    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];
                    Severity: Minor
                    Found in parser-sdk/nodejs/parser-wrapper.js - About 1 hr to fix

                      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("}"))
                      Severity: Minor
                      Found in scanners/kubeaudit/parser/parser.js - About 1 hr to fix

                        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)
                        Severity: Minor
                        Found in operator/apis/execution/v1/zz_generated.deepcopy.go - About 1 hr to fix

                          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(":");
                          Severity: Minor
                          Found in scanners/ssh-audit/parser/parser.js - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if port.Port == 80 ||
                                        port.Port == 8080 ||
                                        port.Port == 443 ||
                                        port.Port == 8443 ||
                                        // Node.js
                            Severity: Critical
                            Found in auto-discovery/kubernetes/controllers/service_scan_controller.go - About 1 hr to fix

                              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)) {
                              Severity: Minor
                              Found in documentation/src/docs.build.js - About 1 hr to fix

                                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)) {
                                Severity: Minor
                                Found in parser-sdk/nodejs/parser-wrapper.js - About 1 hr to fix

                                  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",
                                  Severity: Minor
                                  Found in hooks/notification/hook/Notifiers/EMailNotifier.test.ts - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language