cyberark/secrets-provider-for-k8s

View on GitHub

Showing 22 of 27 total issues

Method K8sProvider.createSecretData has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring.
Open

func (p *K8sProvider) createSecretData(conjurSecrets map[string][]byte) map[string]map[string][]byte {
    _, isFetchAll := p.secretsState.updateDestinations["*"]

    secretData := map[string]map[string][]byte{}
    for variableID, secretValue := range conjurSecrets {
Severity: Minor
Found in pkg/secrets/k8s_secrets_storage/provide_conjur_secrets.go - About 5 hrs 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 DeployTestAppWithHelm has 66 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func DeployTestAppWithHelm(client klient.Client, id string) error {
    // create Deployment
    var replicas int32 = 1
    deployment := appsv1.Deployment{
        TypeMeta: metav1.TypeMeta{
Severity: Minor
Found in e2e/helm_utils.go - About 1 hr to fix

    Function CreateK8sRole has 61 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func CreateK8sRole(client klient.Client, id string) error {
        // create ServiceAccount
        serviceAccount := corev1.ServiceAccount{
            TypeMeta: metav1.TypeMeta{
                APIVersion: "v1",
    Severity: Minor
    Found in e2e/helm_utils.go - About 1 hr to fix

      Method K8sProvider.createSecretData has 54 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (p *K8sProvider) createSecretData(conjurSecrets map[string][]byte) map[string]map[string][]byte {
          _, isFetchAll := p.secretsState.updateDestinations["*"]
      
          secretData := map[string]map[string][]byte{}
          for variableID, secretValue := range conjurSecrets {
      Severity: Minor
      Found in pkg/secrets/k8s_secrets_storage/provide_conjur_secrets.go - About 1 hr to fix

        Function startSecretsProviderWithDeps has 51 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func startSecretsProviderWithDeps(
            annotationsFilePath string,
            secretsBasePath string,
            templatesBasePath string,
            retrieverFactory conjur.RetrieverFactory,
        Severity: Minor
        Found in pkg/entrypoint/entrypoint.go - About 1 hr to fix

          Function secretsProvider has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              ctx context.Context,
              tracer trace.Tracer,
              secretsBasePath string,
              templatesBasePath string,
              secretRetriever conjur.RetrieveSecretsFunc,
          Severity: Minor
          Found in pkg/entrypoint/entrypoint.go - About 45 mins to fix

            Function FetchSecretsForGroups has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
            Open

            func FetchSecretsForGroups(
                depRetrieveSecrets conjur.RetrieveSecretsFunc,
                secretGroups []*SecretGroup,
                traceContext context.Context,
            ) (map[string][]*Secret, error) {
            Severity: Minor
            Found in pkg/secrets/pushtofile/retrieve_secrets.go - About 45 mins 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 DeploySecretsProviderJobWithHelm has 7 return statements (exceeds 4 allowed).
            Open

            func DeploySecretsProviderJobWithHelm(cfg *envconf.Config, id string, chartPaths ...string) error {
                // set conjur cert to file
                err := CreateConjurCertFile(cfg.Client())
                if err != nil {
                    return err
            Severity: Major
            Found in e2e/helm_utils.go - About 45 mins to fix

              Function CopyFileIntoPod has 7 return statements (exceeds 4 allowed).
              Open

              func CopyFileIntoPod(client klient.Client, podName string, namespace string, containerName string, src string, dst string) error {
                  // create client-go clientset
                  clientset, err := kubernetes.NewForConfig(client.RESTConfig())
                  if err != nil {
                      return fmt.Errorf("unable to initialize K8s client: %v", err)
              Severity: Major
              Found in e2e/rotations_utils.go - About 45 mins to fix

                Method ConjurMockClient.RetrieveBatchSecretsSafe has 7 return statements (exceeds 4 allowed).
                Open

                func (mc *ConjurMockClient) RetrieveBatchSecretsSafe(variableIDs []string) (map[string][]byte, error) {
                    if mc.ErrOnExecute != nil {
                        return nil, mc.ErrOnExecute
                    }
                
                
                Severity: Major
                Found in pkg/secrets/clients/conjur/mocks/conjur_client.go - About 45 mins to fix

                  Function startSecretsProviderWithDeps has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      annotationsFilePath string,
                      secretsBasePath string,
                      templatesBasePath string,
                      retrieverFactory conjur.RetrieverFactory,
                      providerFactory secrets.ProviderFactory,
                  Severity: Minor
                  Found in pkg/entrypoint/entrypoint.go - About 45 mins to fix

                    Function RunCommandInSecretsProviderPod has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    func RunCommandInSecretsProviderPod(client klient.Client, labelSelector string, container string, command []string, stdout *bytes.Buffer, stderr *bytes.Buffer) error {
                    Severity: Minor
                    Found in e2e/k8s_utils.go - About 45 mins to fix

                      Function CopyFileIntoPod has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      func CopyFileIntoPod(client klient.Client, podName string, namespace string, containerName string, src string, dst string) error {
                      Severity: Minor
                      Found in e2e/rotations_utils.go - About 45 mins to fix

                        Function ScaleDeployment has 6 return statements (exceeds 4 allowed).
                        Open

                        func ScaleDeployment(client klient.Client, deploymentName string, namespace string, labelSelector string, replicas int32) error {
                            mergePatch, err := json.Marshal(map[string]interface{}{
                                "spec": map[string]interface{}{
                                    "replicas": replicas,
                                },
                        Severity: Major
                        Found in e2e/k8s_utils.go - About 40 mins to fix

                          Function newSecretGroup has 6 return statements (exceeds 4 allowed).
                          Open

                          func newSecretGroup(groupName string, annotations map[string]string, c Config) (*SecretGroup, []error) {
                              groupSecrets := annotations[secretGroupPrefix+groupName]
                              filePath := annotations[secretGroupFilePathPrefix+groupName]
                              fileFormat := annotations[secretGroupFileFormatPrefix+groupName]
                          
                          
                          Severity: Major
                          Found in pkg/secrets/pushtofile/secret_group.go - About 40 mins to fix

                            Function ScaleDeployment has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            func ScaleDeployment(client klient.Client, deploymentName string, namespace string, labelSelector string, replicas int32) error {
                            Severity: Minor
                            Found in e2e/k8s_utils.go - About 35 mins to fix

                              Method secretRetriever.Retrieve has 5 return statements (exceeds 4 allowed).
                              Open

                              func (retriever secretRetriever) Retrieve(variableIDs []string, traceContext context.Context) (map[string][]byte, error) {
                                  authn := retriever.authn
                              
                                  err := authn.AuthenticateWithContext(traceContext)
                                  if err != nil {
                              Severity: Major
                              Found in pkg/secrets/clients/conjur/conjur_secrets_retriever.go - About 35 mins to fix

                                Function collectTemplate has 5 return statements (exceeds 4 allowed).
                                Open

                                func collectTemplate(groupName string, annotations map[string]string, c Config) (string, error) {
                                    annotationTemplate := annotations[secretGroupFileTemplatePrefix+groupName]
                                
                                    configmapTemplate, err := readTemplateFromFile(groupName, annotations, c)
                                    if os.IsNotExist(err) {
                                Severity: Major
                                Found in pkg/secrets/pushtofile/secret_group.go - About 35 mins to fix

                                  Method ConjurMockClient.Resources has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (mc *ConjurMockClient) Resources(filter *conjurapi.ResourceFilter) (resources []map[string]interface{}, err error) {
                                      if mc.ReturnNoSecrets {
                                          return []map[string]interface{}{}, nil
                                      }
                                  
                                  
                                  Severity: Major
                                  Found in pkg/secrets/clients/conjur/mocks/conjur_client.go - About 35 mins to fix

                                    Function startSecretsProviderWithDeps has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func startSecretsProviderWithDeps(
                                        annotationsFilePath string,
                                        secretsBasePath string,
                                        templatesBasePath string,
                                        retrieverFactory conjur.RetrieverFactory,
                                    Severity: Major
                                    Found in pkg/entrypoint/entrypoint.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language