Showing 195 of 515 total issues
Function openPorts
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
newHost.openPorts = openPorts.map(portItem => {
// console.log(JSON.stringify(portItem, null, 4))
const port = parseInt(portItem.$.portid, 10);
const protocol = portItem.$.protocol;
Method ScanCompletionHookSpec.DeepCopyInto
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (in *ScanCompletionHookSpec) DeepCopyInto(out *ScanCompletionHookSpec) {
*out = *in
if in.ImagePullSecrets != nil {
in, out := &in.ImagePullSecrets, &out.ImagePullSecrets
*out = make([]corev1.LocalObjectReference, len(*in))
Method ScanReconciler.startParser
has 12 return statements (exceeds 4 allowed). Open
func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
ctx := context.Background()
namespacedName := fmt.Sprintf("%s/%s", scan.Namespace, scan.Name)
log := r.Log.WithValues("scan_parse", namespacedName)
Function main
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function main() {
let scan;
try {
const { body } = await k8sApi.getNamespacedCustomObject(
"execution.securecodebox.io",
Function getPredicatesForEnabledPerNamespace
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func getPredicatesForEnabledPerNamespace(client client.Client, log logr.Logger) predicate.Predicate {
return predicate.Funcs{
CreateFunc: func(event event.CreateEvent) bool {
if val, ok := event.Object.GetAnnotations()["auto-discovery.securecodebox.io/ignore"]; ok && val == "true" {
Function convertTrivyK8sFindingToSCBFinding
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
function convertTrivyK8sFindingToSCBFinding(trivyK8sFinding, clusterName, namespace, kind, k8sName, target, clazz, type, categoryName) {
Function transformRecommendationToFinding
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function transformRecommendationToFinding(
recommendationSeverityLevel,
value,
destination
) {
Function parseResultFile
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseResultFile(fileContent) {
let targetList = [];
for(const rawTarget of fileContent) {
if (Object.keys(rawTarget).length > 0) { //Check for empty target
Function parse
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function parse(fileContent) {
if (!fileContent || !fileContent.results || fileContent.results.length == 0) {
return [];
}
Function transformNMAPScripts
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function transformNMAPScripts(hosts) {
let scriptFindings = [];
for(const host of hosts) {
- 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 __configure_scanner
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def __configure_scanner(
self, zap_scanner: ascan, scanner_config: collections.OrderedDict
):
"""Starts a ZAP ActiveScan with the given name for the scanners configuration, based on the given configuration and ZAP instance.
- 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 configure_spider
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def configure_spider(self, spider_config: collections.OrderedDict):
"""Configures a ZAP Ajax Spider with the given spider configuration, based on the running ZAP instance.
Parameters
----------
- 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 __start_scanner_with_config
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def __start_scanner_with_config(
self, url: str, scanner_config: collections.OrderedDict
) -> int:
"""Starts a ZAP ActiveScan with the given name for the scanners configuration, based on the given configuration and ZAP instance.
- 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 parseK8sScanResultResource
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseK8sScanResultResource(clusterName, resourceItem, reject) {
let findings = [];
const {Namespace: namespace, Kind: kind, Name: name, Results} = resourceItem;
const results = Results || [];
Function transformToFindings
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function transformToFindings(targets) {
const targetFindings = targets.map(target => {
let finding = {
name: target.uri,
Function getCascadingRulesForScan
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getCascadingRulesForScan(scan: Scan) {
if (scan.spec.cascades === undefined || scan.spec.cascades === null) {
console.log("Skipping cascades as no selector was defined.");
return [];
}
Method init
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void init() throws IOException {
final ClientBuilder clientBuilder;
if (env.isDev()) {
// loading the out-of-cluster config, a kubeconfig from file-system
Method ServiceScanReconciler.Reconcile
has 10 return statements (exceeds 4 allowed). Open
func (r *ServiceScanReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log
log.V(8).Info("Something happened to a service", "service", req.Name, "namespace", req.Namespace)
Method ScanReconciler.processPendingHook
has 10 return statements (exceeds 4 allowed). Open
func (r *ScanReconciler) processPendingHook(scan *executionv1.Scan, status *executionv1.HookStatus, jobType string) error {
ctx := context.Background()
var err error
var hookName string
Method equals
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
- 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"