Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDAP Automation CLI Bug User ref alias incorrect #80

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

georgepstaylor
Copy link
Member

No description provided.

@georgepstaylor georgepstaylor requested a review from a team as a code owner November 11, 2024 16:30
Copy link
Contributor

🚨 Python code is not properly formatted. Click to expand.
9 files already formatted

Please run ruff format to format the code.

Copy link
Contributor

🚨 Linting errors found in Python code. Click to expand.
cli/__init__.py:143:1: SyntaxError: Expected an indented block after function definition
    |
143 | @click.command()
    | ^
144 | @click.option(
145 |     "-t",
    |

cli/ldap_cmds/rbac.py:9:5: F401 [*] `cli.ldap_cmds.ldap_connect` imported but unused
   |
 8 | from cli.ldap_cmds import (
 9 |     ldap_connect,
   |     ^^^^^^^^^^^^ F401
10 | )
11 | from cli import (
   |
   = help: Remove unused import: `cli.ldap_cmds.ldap_connect`

cli/ldap_cmds/rbac.py:143:23: F541 [*] f-string without any placeholders
    |
141 |         )
142 |     except Exception as e:
143 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
144 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:185:23: F541 [*] f-string without any placeholders
    |
183 |         )
184 |     except Exception as e:
185 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
186 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:244:23: F541 [*] f-string without any placeholders
    |
242 |         )
243 |     except Exception as e:
244 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
245 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:266:35: F841 [*] Local variable `no_such_object_e` is assigned to but never used
    |
264 |         )
265 |         tree.reverse()
266 |     except ldap.NO_SUCH_OBJECT as no_such_object_e:
    |                                   ^^^^^^^^^^^^^^^^ F841
267 |         log.debug("Entire policy ou does not exist, no need to delete child objects")
268 |         tree = None
    |
    = help: Remove assignment to unused variable `no_such_object_e`

cli/ldap_cmds/rbac.py:336:23: F541 [*] f-string without any placeholders
    |
334 |         )
335 |     except Exception as e:
336 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
337 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:361:39: F841 [*] Local variable `no_such_object_e` is assigned to but never used
    |
359 |             )
360 |             tree.reverse()
361 |         except ldap.NO_SUCH_OBJECT as no_such_object_e:
    |                                       ^^^^^^^^^^^^^^^^ F841
362 |             log.debug("Entire role ou does not exist, no need to delete child objects")
363 |             tree = None
    |
    = help: Remove assignment to unused variable `no_such_object_e`

cli/ldap_cmds/rbac.py:430:23: F541 [*] f-string without any placeholders
    |
428 |         )
429 |     except Exception as e:
430 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
431 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:446:43: F821 Undefined name `dn`
    |
444 |         # loop through the records
445 |         for entry in records.all_records:
446 |             log.info(f"Got entry record: {dn}")
    |                                           ^^ F821
447 |             # add the record to ldap
448 |             try:
    |

cli/ldap_cmds/rbac.py:474:23: F541 [*] f-string without any placeholders
    |
472 |         )
473 |     except Exception as e:
474 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
475 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:478:23: F541 [*] f-string without any placeholders
    |
477 |     except Exception as e:
478 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
479 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/user.py:349:13: F841 Local variable `removed` is assigned to but never used
    |
347 |                 log.debug(ldap_connection_action.result)
348 |         elif remove:
349 |             removed = 0
    |             ^^^^^^^ F841
350 |             not_removed = 0
351 |             failed = 0
    |
    = help: Remove assignment to unused variable `removed`

cli/ldap_cmds/user.py:350:13: F841 Local variable `not_removed` is assigned to but never used
    |
348 |         elif remove:
349 |             removed = 0
350 |             not_removed = 0
    |             ^^^^^^^^^^^ F841
351 |             failed = 0
352 |             ldap_connection_action.delete(
    |
    = help: Remove assignment to unused variable `not_removed`

cli/ldap_cmds/user.py:432:13: E722 Do not use bare `except`
    |
430 |                 connection.commit()
431 |                 log.info("Committed changes to database successfully")
432 |             except:
    |             ^^^^^^ E722
433 |                 log.exception(f"Failed to update notes for user {user}")
434 |         connection.close()
    |

cli/ldap_cmds/user.py:533:9: E722 Do not use bare `except`
    |
531 |             connection.commit()
532 |             log.info("Committed changes to database successfully")
533 |         except:
    |         ^^^^^^ E722
534 |             log.exception(f"Failed to update END_DATE for user {user_dn}")
535 |     connection.close()
    |

Found 16 errors.
[*] 10 fixable with the `--fix` option (2 hidden fixes can be enabled with the `--unsafe-fixes` option).

Tip: You can run ruff check --fix to fix automatically fixable errors.

Copy link
Contributor

🚨 Linting errors found in Python code. Click to expand.
cli/ldap_cmds/rbac.py:9:5: F401 [*] `cli.ldap_cmds.ldap_connect` imported but unused
   |
 8 | from cli.ldap_cmds import (
 9 |     ldap_connect,
   |     ^^^^^^^^^^^^ F401
10 | )
11 | from cli import (
   |
   = help: Remove unused import: `cli.ldap_cmds.ldap_connect`

cli/ldap_cmds/rbac.py:143:23: F541 [*] f-string without any placeholders
    |
141 |         )
142 |     except Exception as e:
143 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
144 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:185:23: F541 [*] f-string without any placeholders
    |
183 |         )
184 |     except Exception as e:
185 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
186 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:244:23: F541 [*] f-string without any placeholders
    |
242 |         )
243 |     except Exception as e:
244 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
245 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:266:35: F841 [*] Local variable `no_such_object_e` is assigned to but never used
    |
264 |         )
265 |         tree.reverse()
266 |     except ldap.NO_SUCH_OBJECT as no_such_object_e:
    |                                   ^^^^^^^^^^^^^^^^ F841
267 |         log.debug("Entire policy ou does not exist, no need to delete child objects")
268 |         tree = None
    |
    = help: Remove assignment to unused variable `no_such_object_e`

cli/ldap_cmds/rbac.py:336:23: F541 [*] f-string without any placeholders
    |
334 |         )
335 |     except Exception as e:
336 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
337 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:361:39: F841 [*] Local variable `no_such_object_e` is assigned to but never used
    |
359 |             )
360 |             tree.reverse()
361 |         except ldap.NO_SUCH_OBJECT as no_such_object_e:
    |                                       ^^^^^^^^^^^^^^^^ F841
362 |             log.debug("Entire role ou does not exist, no need to delete child objects")
363 |             tree = None
    |
    = help: Remove assignment to unused variable `no_such_object_e`

cli/ldap_cmds/rbac.py:430:23: F541 [*] f-string without any placeholders
    |
428 |         )
429 |     except Exception as e:
430 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
431 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:446:43: F821 Undefined name `dn`
    |
444 |         # loop through the records
445 |         for entry in records.all_records:
446 |             log.info(f"Got entry record: {dn}")
    |                                           ^^ F821
447 |             # add the record to ldap
448 |             try:
    |

cli/ldap_cmds/rbac.py:474:23: F541 [*] f-string without any placeholders
    |
472 |         )
473 |     except Exception as e:
474 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
475 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:478:23: F541 [*] f-string without any placeholders
    |
477 |     except Exception as e:
478 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
479 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/user.py:349:13: F841 Local variable `removed` is assigned to but never used
    |
347 |                 log.debug(ldap_connection_action.result)
348 |         elif remove:
349 |             removed = 0
    |             ^^^^^^^ F841
350 |             not_removed = 0
351 |             failed = 0
    |
    = help: Remove assignment to unused variable `removed`

cli/ldap_cmds/user.py:350:13: F841 Local variable `not_removed` is assigned to but never used
    |
348 |         elif remove:
349 |             removed = 0
350 |             not_removed = 0
    |             ^^^^^^^^^^^ F841
351 |             failed = 0
352 |             ldap_connection_action.delete(
    |
    = help: Remove assignment to unused variable `not_removed`

cli/ldap_cmds/user.py:432:13: E722 Do not use bare `except`
    |
430 |                 connection.commit()
431 |                 log.info("Committed changes to database successfully")
432 |             except:
    |             ^^^^^^ E722
433 |                 log.exception(f"Failed to update notes for user {user}")
434 |         connection.close()
    |

cli/ldap_cmds/user.py:533:9: E722 Do not use bare `except`
    |
531 |             connection.commit()
532 |             log.info("Committed changes to database successfully")
533 |         except:
    |         ^^^^^^ E722
534 |             log.exception(f"Failed to update END_DATE for user {user_dn}")
535 |     connection.close()
    |

Found 15 errors.
[*] 10 fixable with the `--fix` option (2 hidden fixes can be enabled with the `--unsafe-fixes` option).

Tip: You can run ruff check --fix to fix automatically fixable errors.

Copy link
Contributor

🚨 Python code is not properly formatted. Click to expand.
Would reformat: cli/__init__.py
1 file would be reformatted, 9 files already formatted

Please run ruff format to format the code.

Copy link
Contributor

✅ All Python code is properly formatted.

Copy link
Contributor

🚨 Linting errors found in Python code. Click to expand.
cli/ldap_cmds/rbac.py:9:5: F401 [*] `cli.ldap_cmds.ldap_connect` imported but unused
   |
 8 | from cli.ldap_cmds import (
 9 |     ldap_connect,
   |     ^^^^^^^^^^^^ F401
10 | )
11 | from cli import (
   |
   = help: Remove unused import: `cli.ldap_cmds.ldap_connect`

cli/ldap_cmds/rbac.py:143:23: F541 [*] f-string without any placeholders
    |
141 |         )
142 |     except Exception as e:
143 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
144 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:185:23: F541 [*] f-string without any placeholders
    |
183 |         )
184 |     except Exception as e:
185 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
186 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:244:23: F541 [*] f-string without any placeholders
    |
242 |         )
243 |     except Exception as e:
244 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
245 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:266:35: F841 [*] Local variable `no_such_object_e` is assigned to but never used
    |
264 |         )
265 |         tree.reverse()
266 |     except ldap.NO_SUCH_OBJECT as no_such_object_e:
    |                                   ^^^^^^^^^^^^^^^^ F841
267 |         log.debug("Entire policy ou does not exist, no need to delete child objects")
268 |         tree = None
    |
    = help: Remove assignment to unused variable `no_such_object_e`

cli/ldap_cmds/rbac.py:336:23: F541 [*] f-string without any placeholders
    |
334 |         )
335 |     except Exception as e:
336 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
337 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:361:39: F841 [*] Local variable `no_such_object_e` is assigned to but never used
    |
359 |             )
360 |             tree.reverse()
361 |         except ldap.NO_SUCH_OBJECT as no_such_object_e:
    |                                       ^^^^^^^^^^^^^^^^ F841
362 |             log.debug("Entire role ou does not exist, no need to delete child objects")
363 |             tree = None
    |
    = help: Remove assignment to unused variable `no_such_object_e`

cli/ldap_cmds/rbac.py:430:23: F541 [*] f-string without any placeholders
    |
428 |         )
429 |     except Exception as e:
430 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
431 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:446:43: F821 Undefined name `dn`
    |
444 |         # loop through the records
445 |         for entry in records.all_records:
446 |             log.info(f"Got entry record: {dn}")
    |                                           ^^ F821
447 |             # add the record to ldap
448 |             try:
    |

cli/ldap_cmds/rbac.py:474:23: F541 [*] f-string without any placeholders
    |
472 |         )
473 |     except Exception as e:
474 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
475 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:478:23: F541 [*] f-string without any placeholders
    |
477 |     except Exception as e:
478 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
479 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/user.py:349:13: F841 Local variable `removed` is assigned to but never used
    |
347 |                 log.debug(ldap_connection_action.result)
348 |         elif remove:
349 |             removed = 0
    |             ^^^^^^^ F841
350 |             not_removed = 0
351 |             failed = 0
    |
    = help: Remove assignment to unused variable `removed`

cli/ldap_cmds/user.py:350:13: F841 Local variable `not_removed` is assigned to but never used
    |
348 |         elif remove:
349 |             removed = 0
350 |             not_removed = 0
    |             ^^^^^^^^^^^ F841
351 |             failed = 0
352 |             ldap_connection_action.delete(
    |
    = help: Remove assignment to unused variable `not_removed`

cli/ldap_cmds/user.py:432:13: E722 Do not use bare `except`
    |
430 |                 connection.commit()
431 |                 log.info("Committed changes to database successfully")
432 |             except:
    |             ^^^^^^ E722
433 |                 log.exception(f"Failed to update notes for user {user}")
434 |         connection.close()
    |

cli/ldap_cmds/user.py:533:9: E722 Do not use bare `except`
    |
531 |             connection.commit()
532 |             log.info("Committed changes to database successfully")
533 |         except:
    |         ^^^^^^ E722
534 |             log.exception(f"Failed to update END_DATE for user {user_dn}")
535 |     connection.close()
    |

Found 15 errors.
[*] 10 fixable with the `--fix` option (2 hidden fixes can be enabled with the `--unsafe-fixes` option).

Tip: You can run ruff check --fix to fix automatically fixable errors.

@georgepstaylor georgepstaylor force-pushed the TM-690-ldap-automation-cli-bug-user branch from f25fe02 to ab50eb2 Compare November 11, 2024 16:38
Copy link
Contributor

✅ All Python code is properly formatted.

Copy link
Contributor

🚨 Linting errors found in Python code. Click to expand.
cli/ldap_cmds/rbac.py:9:5: F401 [*] `cli.ldap_cmds.ldap_connect` imported but unused
   |
 8 | from cli.ldap_cmds import (
 9 |     ldap_connect,
   |     ^^^^^^^^^^^^ F401
10 | )
11 | from cli import (
   |
   = help: Remove unused import: `cli.ldap_cmds.ldap_connect`

cli/ldap_cmds/rbac.py:143:23: F541 [*] f-string without any placeholders
    |
141 |         )
142 |     except Exception as e:
143 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
144 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:185:23: F541 [*] f-string without any placeholders
    |
183 |         )
184 |     except Exception as e:
185 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
186 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:244:23: F541 [*] f-string without any placeholders
    |
242 |         )
243 |     except Exception as e:
244 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
245 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:266:35: F841 [*] Local variable `no_such_object_e` is assigned to but never used
    |
264 |         )
265 |         tree.reverse()
266 |     except ldap.NO_SUCH_OBJECT as no_such_object_e:
    |                                   ^^^^^^^^^^^^^^^^ F841
267 |         log.debug("Entire policy ou does not exist, no need to delete child objects")
268 |         tree = None
    |
    = help: Remove assignment to unused variable `no_such_object_e`

cli/ldap_cmds/rbac.py:336:23: F541 [*] f-string without any placeholders
    |
334 |         )
335 |     except Exception as e:
336 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
337 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:361:39: F841 [*] Local variable `no_such_object_e` is assigned to but never used
    |
359 |             )
360 |             tree.reverse()
361 |         except ldap.NO_SUCH_OBJECT as no_such_object_e:
    |                                       ^^^^^^^^^^^^^^^^ F841
362 |             log.debug("Entire role ou does not exist, no need to delete child objects")
363 |             tree = None
    |
    = help: Remove assignment to unused variable `no_such_object_e`

cli/ldap_cmds/rbac.py:430:23: F541 [*] f-string without any placeholders
    |
428 |         )
429 |     except Exception as e:
430 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
431 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:446:43: F821 Undefined name `dn`
    |
444 |         # loop through the records
445 |         for entry in records.all_records:
446 |             log.info(f"Got entry record: {dn}")
    |                                           ^^ F821
447 |             # add the record to ldap
448 |             try:
    |

cli/ldap_cmds/rbac.py:474:23: F541 [*] f-string without any placeholders
    |
472 |         )
473 |     except Exception as e:
474 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
475 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/rbac.py:478:23: F541 [*] f-string without any placeholders
    |
477 |     except Exception as e:
478 |         log.exception(f"Failed to connect to ldap")
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F541
479 |         raise e
    |
    = help: Remove extraneous `f` prefix

cli/ldap_cmds/user.py:349:13: F841 Local variable `removed` is assigned to but never used
    |
347 |                 log.debug(ldap_connection_action.result)
348 |         elif remove:
349 |             removed = 0
    |             ^^^^^^^ F841
350 |             not_removed = 0
351 |             failed = 0
    |
    = help: Remove assignment to unused variable `removed`

cli/ldap_cmds/user.py:350:13: F841 Local variable `not_removed` is assigned to but never used
    |
348 |         elif remove:
349 |             removed = 0
350 |             not_removed = 0
    |             ^^^^^^^^^^^ F841
351 |             failed = 0
352 |             ldap_connection_action.delete(
    |
    = help: Remove assignment to unused variable `not_removed`

cli/ldap_cmds/user.py:432:13: E722 Do not use bare `except`
    |
430 |                 connection.commit()
431 |                 log.info("Committed changes to database successfully")
432 |             except:
    |             ^^^^^^ E722
433 |                 log.exception(f"Failed to update notes for user {user}")
434 |         connection.close()
    |

cli/ldap_cmds/user.py:533:9: E722 Do not use bare `except`
    |
531 |             connection.commit()
532 |             log.info("Committed changes to database successfully")
533 |         except:
    |         ^^^^^^ E722
534 |             log.exception(f"Failed to update END_DATE for user {user_dn}")
535 |     connection.close()
    |

Found 15 errors.
[*] 10 fixable with the `--fix` option (2 hidden fixes can be enabled with the `--unsafe-fixes` option).

Tip: You can run ruff check --fix to fix automatically fixable errors.

@georgepstaylor georgepstaylor merged commit b8a523b into main Nov 11, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants