Language: TypeScript
Label: safe
CWE: CWE-287 \u2014 Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.

Code:
async function predeploy(
  integrationId: string,
  serviceAccountApiToken: string,
  namespace: string,
): Promise<void> {
  try {
    const secretName = 'snyk-monitor';
    console.log(`Creating namespace ${namespace} and secret ${secretName}`);

    try {
      await kubectl.createNamespace(namespace);
    } catch (error) {
      console.log(`Namespace ${namespace} already exist`);
    }
    const gcrDockercfg = process.env['PRIVATE_REGISTRIES_DOCKERCFG'] || '{}';
    await kubectl.createSecret(secretName, namespace, {
      'dockercfg.json': gcrDockercfg,
      integrationId,
      serviceAccountApiToken,
    });
    await createRegistriesConfigMap(namespace);
    console.log(`Namespace ${namespace} and secret ${secretName} created`);
  } catch (error) {
    console.log(
      'Could not create namespace and secret, they probably already exist',
    );
  }
}