Yelp / detect-secrets

An enterprise friendly way of detecting and preventing secrets in code.
Apache License 2.0
3.76k stars 467 forks source link

Secrets are not found in Jupyter Notebooks #781

Closed mosc9575 closed 4 months ago

mosc9575 commented 9 months ago

If I open an new Jupyter Notebook (in JupyterLab 4.0.9) and write in the first cell

def my_very_secret_function(my_password = "bar"):
    pass

see secret is not found while using detect secrets as a pre-commit hook.

This is because the cell has the following form in the saved file.

  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aa11ab85-ce4e-4803-92c9-0f48e2ce4c52",
   "metadata": {},
   "outputs": [],
   "source": [
    "def my_very_secret_function(my_password = \"bar\"):\n",
    "    pass"
   ]
  }

As you can see there is a backslash \ before the quotation mark ". I think because of this no regular expressions matches the secret.

Detect secrets version : 1.4.0 Python version : 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:07:37) [GCC 12.3.0] IPython version : 8.14.0 Tornado version : 6.3.3 Operating system : Linux-4.19.0-21-amd64-x86_64-with-glibc2.35 JupyterLab version : 4.0.9

lorenzodb1 commented 4 months ago

Closing as duplicate of https://github.com/Yelp/detect-secrets/issues/780.