cyberark/secrets-provider-for-k8s

View on GitHub

Showing 27 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

                              Similar blocks of code found in 5 locations. Consider refactoring.
                              Open

                              func GetSecret(client klient.Client, secretName string) (*corev1.Secret, error) {
                                  var secret corev1.Secret
                                  err := client.Resources().Get(context.TODO(), secretName, SecretsProviderNamespace(), &secret)
                                  if err != nil {
                                      return &secret, err
                              Severity: Major
                              Found in e2e/k8s_utils.go and 4 other locations - About 35 mins to fix
                              e2e/k8s_utils.go on lines 125..132
                              e2e/k8s_utils.go on lines 146..153
                              e2e/k8s_utils.go on lines 176..183
                              e2e/k8s_utils.go on lines 227..234

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 107.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Similar blocks of code found in 5 locations. Consider refactoring.
                              Open

                              func GetConfigMap(client klient.Client, configMapName string) (*corev1.ConfigMap, error) {
                                  var configMap corev1.ConfigMap
                                  err := client.Resources().Get(context.TODO(), configMapName, SecretsProviderNamespace(), &configMap)
                                  if err != nil {
                                      return &configMap, err
                              Severity: Major
                              Found in e2e/k8s_utils.go and 4 other locations - About 35 mins to fix
                              e2e/k8s_utils.go on lines 125..132
                              e2e/k8s_utils.go on lines 146..153
                              e2e/k8s_utils.go on lines 155..162
                              e2e/k8s_utils.go on lines 176..183

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 107.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Similar blocks of code found in 5 locations. Consider refactoring.
                              Open

                              func GetDeployment(client klient.Client, deploymentName string) (*appsv1.Deployment, error) {
                                  var deployment appsv1.Deployment
                                  err := client.Resources().Get(context.TODO(), deploymentName, SecretsProviderNamespace(), &deployment)
                                  if err != nil {
                                      return &deployment, err
                              Severity: Major
                              Found in e2e/k8s_utils.go and 4 other locations - About 35 mins to fix
                              e2e/k8s_utils.go on lines 146..153
                              e2e/k8s_utils.go on lines 155..162
                              e2e/k8s_utils.go on lines 176..183
                              e2e/k8s_utils.go on lines 227..234

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 107.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Similar blocks of code found in 5 locations. Consider refactoring.
                              Open

                              func GetJob(client klient.Client, jobName string) (*batchv1.Job, error) {
                                  var job batchv1.Job
                                  err := client.Resources().Get(context.TODO(), jobName, SecretsProviderNamespace(), &job)
                                  if err != nil {
                                      return &job, err
                              Severity: Major
                              Found in e2e/k8s_utils.go and 4 other locations - About 35 mins to fix
                              e2e/k8s_utils.go on lines 125..132
                              e2e/k8s_utils.go on lines 155..162
                              e2e/k8s_utils.go on lines 176..183
                              e2e/k8s_utils.go on lines 227..234

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 107.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              Severity
                              Category
                              Status
                              Source
                              Language