io4it 2.1.7.3__tar.gz → 2.1.8.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {io4it-2.1.7.3 → io4it-2.1.8.4}/PKG-INFO +1 -1
  2. {io4it-2.1.7.3 → io4it-2.1.8.4}/io4it.egg-info/PKG-INFO +1 -1
  3. {io4it-2.1.7.3 → io4it-2.1.8.4}/io4it.egg-info/SOURCES.txt +10 -1
  4. {io4it-2.1.7.3 → io4it-2.1.8.4}/io4it.egg-info/requires.txt +2 -0
  5. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/utils/mail.py +10 -10
  6. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/utils/offuscation_basique.py +111 -62
  7. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/OWDoclingASR.py +215 -0
  8. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/OWMD2HTML.py +186 -0
  9. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/OWParserHTML.py +222 -0
  10. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/OWWebSearch.py +306 -0
  11. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/designer/owmd2html.ui +169 -0
  12. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/designer/owparserhtml.ui +115 -0
  13. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/designer/owwebsearch.ui +199 -0
  14. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/icons/html.png +0 -0
  15. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/icons/owmd2html.svg +41 -0
  16. io4it-2.1.8.4/orangecontrib/IO4IT/widgets/icons/websearch.png +0 -0
  17. {io4it-2.1.7.3 → io4it-2.1.8.4}/setup.py +3 -1
  18. {io4it-2.1.7.3 → io4it-2.1.8.4}/io4it.egg-info/dependency_links.txt +0 -0
  19. {io4it-2.1.7.3 → io4it-2.1.8.4}/io4it.egg-info/entry_points.txt +0 -0
  20. {io4it-2.1.7.3 → io4it-2.1.8.4}/io4it.egg-info/namespace_packages.txt +0 -0
  21. {io4it-2.1.7.3 → io4it-2.1.8.4}/io4it.egg-info/top_level.txt +0 -0
  22. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/__init__.py +0 -0
  23. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/ocr_function/__init__.py +0 -0
  24. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/ocr_function/word_converter.py +0 -0
  25. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/utils/__init__.py +0 -0
  26. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/utils/pool_exec_utils.py +0 -0
  27. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/utils/secret_manager.py +0 -0
  28. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/utils/utils_md.py +0 -0
  29. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWChatGpt.py +0 -0
  30. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWDeep_Search.py +0 -0
  31. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWDoclingToMarkdown.py +0 -0
  32. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWExportMarkdown.py +0 -0
  33. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWExtractTablesDocxToXlsx.py +0 -0
  34. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWInboxMailMonitoring.py +0 -0
  35. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWMarkdownLoader.py +0 -0
  36. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWMarkdownizer.py +0 -0
  37. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWOfficeNormalizer.py +0 -0
  38. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWPdfType.py +0 -0
  39. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWProcessPoolExecutor.py +0 -0
  40. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWS3Uploader.py +0 -0
  41. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWS3downloader.py +0 -0
  42. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWS3list.py +0 -0
  43. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWSpeechToText.py +0 -0
  44. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWmailLoader.py +0 -0
  45. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWmailSender.py +0 -0
  46. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/OWwordpdf2docx.py +0 -0
  47. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/__init__.py +0 -0
  48. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/__init__.py +0 -0
  49. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/nogui.ui +0 -0
  50. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/ow_file_ext_selector.ui +0 -0
  51. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owchatgpt.ui +0 -0
  52. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owdeepsearch.ui +0 -0
  53. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owdoclingasr.ui +0 -0
  54. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owdoclingtomarkdown.ui +0 -0
  55. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owdocxtoxlsx.ui +0 -0
  56. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owexportmarkdown.ui +0 -0
  57. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owinboxmailmonitoring.ui +0 -0
  58. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owmailloader.ui +0 -0
  59. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owmailsender.ui +0 -0
  60. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owmarkdownizer.ui +0 -0
  61. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owmarkdownloader.ui +0 -0
  62. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owofficenormalizer.ui +0 -0
  63. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owpdftype.ui +0 -0
  64. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owprocesspoolexecutor.ui +0 -0
  65. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owspeechtotext.ui +0 -0
  66. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/owvisualizationer.ui +0 -0
  67. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/designer/wordpdf2docx.ui +0 -0
  68. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/__init__.py +0 -0
  69. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/chatgpt.png +0 -0
  70. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/check_pdf.png +0 -0
  71. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/deepsearch.svg +0 -0
  72. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/dep_md_old.png +0 -0
  73. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/download.png +0 -0
  74. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/export_md.png +0 -0
  75. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/extract_table.png +0 -0
  76. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/file_extensor.png +0 -0
  77. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/list_aws.png +0 -0
  78. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/load_md.png +0 -0
  79. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/mail_loader.png +0 -0
  80. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/mail_writer.png +0 -0
  81. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/md.png +0 -0
  82. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/monitor-email.svg +0 -0
  83. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/office_normalizer.png +0 -0
  84. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/process_pool_executor.png +0 -0
  85. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/speech_to_text.png +0 -0
  86. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/upload.png +0 -0
  87. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/visualizationer.png +0 -0
  88. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons/wordpdf2docx.png +0 -0
  89. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/IO4IT/widgets/icons_dev/__init__.py +0 -0
  90. {io4it-2.1.7.3 → io4it-2.1.8.4}/orangecontrib/__init__.py +0 -0
  91. {io4it-2.1.7.3 → io4it-2.1.8.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: io4it
3
- Version: 2.1.7.3
3
+ Version: 2.1.8.4
4
4
  Home-page:
5
5
  Author:
6
6
  Author-email:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: io4it
3
- Version: 2.1.7.3
3
+ Version: 2.1.8.4
4
4
  Home-page:
5
5
  Author:
6
6
  Author-email:
@@ -1,4 +1,3 @@
1
- setup.cfg
2
1
  setup.py
3
2
  io4it.egg-info/PKG-INFO
4
3
  io4it.egg-info/SOURCES.txt
@@ -19,19 +18,23 @@ orangecontrib/IO4IT/utils/secret_manager.py
19
18
  orangecontrib/IO4IT/utils/utils_md.py
20
19
  orangecontrib/IO4IT/widgets/OWChatGpt.py
21
20
  orangecontrib/IO4IT/widgets/OWDeep_Search.py
21
+ orangecontrib/IO4IT/widgets/OWDoclingASR.py
22
22
  orangecontrib/IO4IT/widgets/OWDoclingToMarkdown.py
23
23
  orangecontrib/IO4IT/widgets/OWExportMarkdown.py
24
24
  orangecontrib/IO4IT/widgets/OWExtractTablesDocxToXlsx.py
25
25
  orangecontrib/IO4IT/widgets/OWInboxMailMonitoring.py
26
+ orangecontrib/IO4IT/widgets/OWMD2HTML.py
26
27
  orangecontrib/IO4IT/widgets/OWMarkdownLoader.py
27
28
  orangecontrib/IO4IT/widgets/OWMarkdownizer.py
28
29
  orangecontrib/IO4IT/widgets/OWOfficeNormalizer.py
30
+ orangecontrib/IO4IT/widgets/OWParserHTML.py
29
31
  orangecontrib/IO4IT/widgets/OWPdfType.py
30
32
  orangecontrib/IO4IT/widgets/OWProcessPoolExecutor.py
31
33
  orangecontrib/IO4IT/widgets/OWS3Uploader.py
32
34
  orangecontrib/IO4IT/widgets/OWS3downloader.py
33
35
  orangecontrib/IO4IT/widgets/OWS3list.py
34
36
  orangecontrib/IO4IT/widgets/OWSpeechToText.py
37
+ orangecontrib/IO4IT/widgets/OWWebSearch.py
35
38
  orangecontrib/IO4IT/widgets/OWmailLoader.py
36
39
  orangecontrib/IO4IT/widgets/OWmailSender.py
37
40
  orangecontrib/IO4IT/widgets/OWwordpdf2docx.py
@@ -50,11 +53,14 @@ orangecontrib/IO4IT/widgets/designer/owmailloader.ui
50
53
  orangecontrib/IO4IT/widgets/designer/owmailsender.ui
51
54
  orangecontrib/IO4IT/widgets/designer/owmarkdownizer.ui
52
55
  orangecontrib/IO4IT/widgets/designer/owmarkdownloader.ui
56
+ orangecontrib/IO4IT/widgets/designer/owmd2html.ui
53
57
  orangecontrib/IO4IT/widgets/designer/owofficenormalizer.ui
58
+ orangecontrib/IO4IT/widgets/designer/owparserhtml.ui
54
59
  orangecontrib/IO4IT/widgets/designer/owpdftype.ui
55
60
  orangecontrib/IO4IT/widgets/designer/owprocesspoolexecutor.ui
56
61
  orangecontrib/IO4IT/widgets/designer/owspeechtotext.ui
57
62
  orangecontrib/IO4IT/widgets/designer/owvisualizationer.ui
63
+ orangecontrib/IO4IT/widgets/designer/owwebsearch.ui
58
64
  orangecontrib/IO4IT/widgets/designer/wordpdf2docx.ui
59
65
  orangecontrib/IO4IT/widgets/icons/__init__.py
60
66
  orangecontrib/IO4IT/widgets/icons/chatgpt.png
@@ -65,6 +71,7 @@ orangecontrib/IO4IT/widgets/icons/download.png
65
71
  orangecontrib/IO4IT/widgets/icons/export_md.png
66
72
  orangecontrib/IO4IT/widgets/icons/extract_table.png
67
73
  orangecontrib/IO4IT/widgets/icons/file_extensor.png
74
+ orangecontrib/IO4IT/widgets/icons/html.png
68
75
  orangecontrib/IO4IT/widgets/icons/list_aws.png
69
76
  orangecontrib/IO4IT/widgets/icons/load_md.png
70
77
  orangecontrib/IO4IT/widgets/icons/mail_loader.png
@@ -72,9 +79,11 @@ orangecontrib/IO4IT/widgets/icons/mail_writer.png
72
79
  orangecontrib/IO4IT/widgets/icons/md.png
73
80
  orangecontrib/IO4IT/widgets/icons/monitor-email.svg
74
81
  orangecontrib/IO4IT/widgets/icons/office_normalizer.png
82
+ orangecontrib/IO4IT/widgets/icons/owmd2html.svg
75
83
  orangecontrib/IO4IT/widgets/icons/process_pool_executor.png
76
84
  orangecontrib/IO4IT/widgets/icons/speech_to_text.png
77
85
  orangecontrib/IO4IT/widgets/icons/upload.png
78
86
  orangecontrib/IO4IT/widgets/icons/visualizationer.png
87
+ orangecontrib/IO4IT/widgets/icons/websearch.png
79
88
  orangecontrib/IO4IT/widgets/icons/wordpdf2docx.png
80
89
  orangecontrib/IO4IT/widgets/icons_dev/__init__.py
@@ -21,4 +21,6 @@ docx2pdf
21
21
  doc2docx
22
22
  msal
23
23
  exchangelib
24
+ html2text
25
+ ddgs
24
26
  CATEGORIT
@@ -310,9 +310,8 @@ def check_new_emails(offusc_conf_agent,type_co, list_agent_email=[]):
310
310
  print(f"Erreur lors du traitement du mail : {e}")
311
311
  elif type_co == "MICROSOFT_EXCHANGE_OAUTH2":
312
312
  try:
313
- client_id, client_secret, tenant_id, user_email= offuscation_basique.lire_config_cli_oauth2(
313
+ client_id, client_secret, tenant_id, user_email= offuscation_basique.lire_config_oauth2(
314
314
  offusc_conf_agent)
315
-
316
315
  authority = f"https://login.microsoftonline.com/{tenant_id}"
317
316
 
318
317
  app = ConfidentialClientApplication(
@@ -437,7 +436,7 @@ def check_new_emails(offusc_conf_agent,type_co, list_agent_email=[]):
437
436
  elif type_co == "MICROSOFT_EXCHANGE_OAUTH2_MICROSOFT_GRAPH":
438
437
  try:
439
438
  print("🔍 [DEBUG] Début de la vérification des emails avec Microsoft Graph OAuth2")
440
- client_id, client_secret, tenant_id, user_email = offuscation_basique.lire_config_cli_oauth2(
439
+ client_id, client_secret, tenant_id, user_email = offuscation_basique.lire_config_oauth2(
441
440
  offusc_conf_agent)
442
441
  print(f"🔍 [DEBUG] Configuration lue - User: {user_email}, Tenant: {tenant_id}")
443
442
 
@@ -677,11 +676,12 @@ def send_mail(expediteur, offusc_conf_agent, destinataire, sujet, contenu_html,
677
676
 
678
677
  # ✅ Ajout d'une ou plusieurs pièces jointes si fournie
679
678
  if piece_jointe_paths:
680
- for piece_path in piece_jointe_paths:
679
+ piece_paths = [f for f in os.listdir(piece_jointe_paths) if os.path.isfile(os.path.join(piece_jointe_paths, f))]
680
+ for piece_path in piece_paths:
681
681
  try:
682
- with open(piece_path, 'rb') as f:
682
+ with open(piece_jointe_paths + "/" + piece_path, 'rb') as f:
683
683
  data = f.read()
684
- nom_fichier = os.path.basename(piece_path)
684
+ nom_fichier = os.path.basename(piece_jointe_paths + "/" +piece_path)
685
685
  type_mime, _ = mimetypes.guess_type(nom_fichier)
686
686
  maintype, subtype = type_mime.split('/') if type_mime else ('application', 'octet-stream')
687
687
  msg.add_attachment(data, maintype=maintype, subtype=subtype, filename=nom_fichier)
@@ -721,7 +721,7 @@ def check_send_new_emails(offusc_conf_agent,type_co):
721
721
  infos["eme"],
722
722
  infos["tit"],
723
723
  infos["txt"],
724
- piece_jointe_paths=None #à rajouter quand PJ ok chemin_dossier_out + "/" + contenu + "/pj"
724
+ piece_jointe_paths= chemin_dossier_out + "/" + contenu + "/pj" #à rajouter quand PJ ok chemin_dossier_out + "/" + contenu + "/pj"
725
725
  )
726
726
  MetManagement.reset_folder(chemin_dossier_in + contenu , recreate=False)
727
727
  MetManagement.reset_folder(chemin_dossier_out + contenu, recreate=False)
@@ -776,9 +776,8 @@ def check_send_new_emails(offusc_conf_agent,type_co):
776
776
  print(f"Erreur lors du traitement du mail : {e}")
777
777
  elif type_co == "MICROSOFT_EXCHANGE_OAUTH2":
778
778
  try:
779
- client_id, client_secret, tenant_id, user_email = offuscation_basique.lire_config_cli_oauth2(
779
+ client_id, client_secret, tenant_id, user_email = offuscation_basique.lire_config_oauth2(
780
780
  offusc_conf_agent)
781
-
782
781
  # Déduire l'alias pour le nom du dossier
783
782
  agent = user_email
784
783
  alias = user_email # tu peux adapter si tu veux un alias distinct plus tard
@@ -860,7 +859,7 @@ def check_send_new_emails(offusc_conf_agent,type_co):
860
859
  elif type_co == "MICROSOFT_EXCHANGE_OAUTH2_MICROSOFT_GRAPH":
861
860
  try:
862
861
  print("📤 [DEBUG] Début de la vérification des emails à envoyer avec Microsoft Graph OAuth2")
863
- client_id, client_secret, tenant_id, user_email = offuscation_basique.lire_config_cli_oauth2(
862
+ client_id, client_secret, tenant_id, user_email = offuscation_basique.lire_config_oauth2(
864
863
  offusc_conf_agent)
865
864
  print(f"📤 [DEBUG] Configuration lue - User: {user_email}, Tenant: {tenant_id}")
866
865
 
@@ -1011,6 +1010,7 @@ if __name__ == "__main__":
1011
1010
  offusc_conf_agents = list_conf_files(type_co)
1012
1011
  while True:
1013
1012
  for offusc_conf_agent in offusc_conf_agents:
1013
+ print("offusc conf agent : ", offusc_conf_agent)
1014
1014
  check_new_emails(offusc_conf_agent,type_co, list_agent_email)
1015
1015
  time.sleep(1)
1016
1016
  check_send_new_emails(offusc_conf_agent,type_co)
@@ -5,11 +5,12 @@ import getpass
5
5
  from cryptography.fernet import Fernet
6
6
  import base64
7
7
 
8
-
9
8
  if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
10
9
  from Orange.widgets.orangecontrib.AAIT.utils import MetManagement
10
+ from Orange.widgets.orangecontrib.IO4IT.utils import secret_manager
11
11
  else:
12
12
  from orangecontrib.AAIT.utils import MetManagement
13
+ from orangecontrib.AAIT.utils import secret_manager
13
14
 
14
15
 
15
16
  # FONCTIOSN D'OBFUSCATION GÉNÉRALES & CHEMIN
@@ -18,10 +19,10 @@ def get_user_key():
18
19
  try:
19
20
  username = getpass.getuser()
20
21
  #try:
21
- #username = os.getlogin()
22
+ #username = os.getlogin()
22
23
 
23
24
  #except OSError:
24
- #username = getpass.getuser()
25
+ #username = getpass.getuser()
25
26
 
26
27
  if not username:
27
28
  raise ValueError("Nom d'utilisateur introuvable")
@@ -34,10 +35,12 @@ def get_user_key():
34
35
  except Exception as e:
35
36
  raise RuntimeError(f"Erreur de génération de clé : {e}")
36
37
 
38
+
37
39
  # Fonction simple de chiffrement/déchiffrement par XOR (non sécurisé mais obscurcissant)
38
40
  def xor_crypt(data: str, key: int) -> str:
39
41
  return ''.join(chr(ord(c) ^ (key & 0xFF)) for c in data)
40
42
 
43
+
41
44
  # Renvoie le chemin absolu vers le sous-dossier « aait_store/keys »
42
45
  def get_keys_dir(type_key: str = "MICROSOFT_EXCHANGE_OAUTH2") -> str:
43
46
  """
@@ -55,6 +58,7 @@ def get_keys_dir(type_key: str = "MICROSOFT_EXCHANGE_OAUTH2") -> str:
55
58
  except Exception as e:
56
59
  raise RuntimeError(f"Erreur création/récupération dossier : {e}")
57
60
 
61
+
58
62
  def get_fernet_key() -> bytes:
59
63
  """
60
64
  Dérive une clé Fernet (32 octets base64) à partir du nom d'utilisateur local.
@@ -63,10 +67,12 @@ def get_fernet_key() -> bytes:
63
67
  digest = hashlib.sha256(username).digest()
64
68
  return base64.urlsafe_b64encode(digest[:32]) # 32 bytes en base64
65
69
 
70
+
66
71
  def encrypt_secure(data: str) -> str:
67
72
  fernet = Fernet(get_fernet_key())
68
73
  return fernet.encrypt(data.encode("utf-8")).decode("utf-8")
69
74
 
75
+
70
76
  def decrypt_secure(data: str) -> str:
71
77
  fernet = Fernet(get_fernet_key())
72
78
  return fernet.decrypt(data.encode("utf-8")).decode("utf-8")
@@ -82,14 +88,15 @@ def save_config(str_type,list_str=[]):
82
88
  return
83
89
  """
84
90
 
91
+
85
92
  ## va lire le fichier de white_list et black_list
86
93
  ## ce fichier et un json du type {"white_list":[], "black_list":[]}
87
94
  ## si pas de fichier ou juste white_liste ou black list il retourne uniquement celui présent
88
95
  def lire_list_email(chemin_fichier):
89
96
  try:
90
- chemin_fichier=MetManagement.get_secret_content_dir()+chemin_fichier
97
+ chemin_fichier = MetManagement.get_secret_content_dir() + chemin_fichier
91
98
  if not os.path.exists(chemin_fichier):
92
- return [[],[]]
99
+ return [[], []]
93
100
  # Lecture du fichier JSON
94
101
  with open(chemin_fichier, "r", encoding="utf-8") as f:
95
102
  contenu = json.load(f)
@@ -102,10 +109,9 @@ def lire_list_email(chemin_fichier):
102
109
  return None
103
110
 
104
111
 
105
-
106
112
  def enregistrer_config_imap4_ssl(agent, my_domain, password, interval_second, alias=""):
107
113
  try:
108
- dossier=get_keys_dir("IMAP4_SSL")
114
+ dossier = get_keys_dir("IMAP4_SSL")
109
115
  # Crée le dossier s'il n'existe pas
110
116
  if not os.path.exists(dossier):
111
117
  os.makedirs(dossier)
@@ -116,10 +122,8 @@ def enregistrer_config_imap4_ssl(agent, my_domain, password, interval_second, al
116
122
 
117
123
  # Nom du fichier (remplace @ par _at_ pour éviter les problèmes)
118
124
  nom_fichier = os.path.join(dossier, f"{agent}{my_domain.replace('@', '_at_')}.json")
119
- if alias=="''" or alias=="\"\"":
120
- alias=""
121
-
122
-
125
+ if alias == "''" or alias == "\"\"":
126
+ alias = ""
123
127
 
124
128
  # Contenu à écrire dans le fichier
125
129
  contenu = {
@@ -141,9 +145,10 @@ def enregistrer_config_imap4_ssl(agent, my_domain, password, interval_second, al
141
145
  print(f"❌ Erreur lors de l'enregistrement : {e}")
142
146
  return 1
143
147
 
144
- def enregistrer_config_owa(mail,alias,server,username,password,interval):
148
+
149
+ def enregistrer_config_owa(mail, alias, server, username, password, interval):
145
150
  try:
146
- dossier=get_keys_dir("MICROSOFT_EXCHANGE_OWA")
151
+ dossier = get_keys_dir("MICROSOFT_EXCHANGE_OWA")
147
152
  # Crée le dossier s'il n'existe pas
148
153
  if not os.path.exists(dossier):
149
154
  os.makedirs(dossier)
@@ -155,13 +160,12 @@ def enregistrer_config_owa(mail,alias,server,username,password,interval):
155
160
  # Nom du fichier (remplace @ par _at_ pour éviter les problèmes)
156
161
  nom_fichier = os.path.join(dossier, f"{alias.replace('@', '_at_')}.json")
157
162
 
158
-
159
163
  # Contenu à écrire dans le fichier
160
164
  contenu = {
161
165
  "mail": mail,
162
166
  "alias": alias,
163
- "server":server,
164
- "username":username,
167
+ "server": server,
168
+ "username": username,
165
169
  "password_encrypted": mdp_chiffre,
166
170
  "interval_second": interval
167
171
  }
@@ -177,6 +181,7 @@ def enregistrer_config_owa(mail,alias,server,username,password,interval):
177
181
  print(f"❌ Erreur lors de l'enregistrement : {e}")
178
182
  return 1
179
183
 
184
+
180
185
  def enregistrer_config_owa_secure(mail, alias, server, username, password, interval):
181
186
  try:
182
187
  dossier = get_keys_dir("MICROSOFT_EXCHANGE_OWA_SECURE")
@@ -205,10 +210,11 @@ def enregistrer_config_owa_secure(mail, alias, server, username, password, inter
205
210
  print(f"❌ Erreur d'enregistrement sécurisé OWA : {e}")
206
211
  return 1
207
212
 
213
+
208
214
  def enregistrer_config_cli_owa_secure():
209
215
  print("\n🔐 Écriture fichier OWA avec chiffrement sécurisé :")
210
216
  mail = input("📧 Mail (nom@domain.com) : ").strip()
211
- alias = mail #input("📛 Alias (visible) : ").strip()
217
+ alias = mail #input("📛 Alias (visible) : ").strip()
212
218
  server = input("🌐 Server : ").strip()
213
219
  username = input("👤 Username (domain\\user) : ").strip()
214
220
  password = input("🔑 Password (non masqué) : ").strip()
@@ -219,6 +225,7 @@ def enregistrer_config_cli_owa_secure():
219
225
  if 0 != enregistrer_config_owa_secure(mail, alias, server, username, password, interval):
220
226
  print("❌ Erreur lors de enregistrer_config_owa_secure !")
221
227
 
228
+
222
229
  def lecture_config_cli_owa_secure():
223
230
  fichier = input("📄 Nom du fichier JSON (sans chemin) : ").strip()
224
231
  cfg = lire_config_owa_secure(fichier)
@@ -234,6 +241,7 @@ def lecture_config_cli_owa_secure():
234
241
  print(f"🔑 password : {cfg[4]}")
235
242
  print(f"⏱️ intervalle : {cfg[5]}s")
236
243
 
244
+
237
245
  def lire_config_owa_secure(chemin_fichier):
238
246
  try:
239
247
  chemin_fichier = os.path.join(get_keys_dir("MICROSOFT_EXCHANGE_OWA_SECURE"), chemin_fichier)
@@ -281,6 +289,32 @@ def lire_config_imap4_ssl(chemin_fichier):
281
289
  print(f"❌ Erreur lors de la lecture : {e}")
282
290
  return None
283
291
 
292
+ def lire_config_oauth2(chemin_fichier):
293
+ try:
294
+ chemin_fichiers = os.path.join(get_keys_dir("MICROSOFT_EXCHANGE_OAUTH2"), chemin_fichier)
295
+ with open(chemin_fichiers, "r", encoding="utf-8") as f:
296
+ contenu = json.load(f)
297
+ if "key" in contenu:
298
+ key = contenu["key"]
299
+ s_m = secret_manager.SecretManager(key)
300
+ contenu_enregistre = s_m.load_all()
301
+ return [contenu_enregistre["client_id"], contenu_enregistre["client_secret"], contenu_enregistre["tenant_id"], contenu_enregistre["user_email"]]
302
+ else :
303
+ key = get_user_key()
304
+ client_id = xor_crypt(contenu["client_id_enc"], key)
305
+ client_secret = xor_crypt(contenu["client_secret_enc"], key)
306
+ tenant_id = xor_crypt(contenu["tenant_id_enc"], key)
307
+ # Retourne les infos de configuration
308
+ return [
309
+ client_id,
310
+ client_secret,
311
+ tenant_id,
312
+ contenu["user_email"]
313
+ ]
314
+ except Exception as e:
315
+ print(f"❌ Erreur lors de la lecture : {e}")
316
+ return None
317
+
284
318
 
285
319
  def lire_config_owa(chemin_fichier):
286
320
  try:
@@ -316,9 +350,10 @@ def enregistrer_config_cli_imap4_ssl():
316
350
  mdp = input("📨mot de passe? : ").strip()
317
351
  interval = int(input("⏱️ Intervalle en secondes : ").strip())
318
352
  alias = input("Nom de l'alias : ").strip()
319
- if 0!= enregistrer_config_imap4_ssl(agent,domaine,mdp,interval,alias):
353
+ if 0 != enregistrer_config_imap4_ssl(agent, domaine, mdp, interval, alias):
320
354
  print("erreur!")
321
355
 
356
+
322
357
  def enregistrer_config_cli_owa():
323
358
  print("\n📝 Écriture d’un fichier de configuration owa :")
324
359
  mail = input("🤖 mail (nom@domain.com) : ").strip()
@@ -327,29 +362,48 @@ def enregistrer_config_cli_owa():
327
362
  username = input("usernamme (domaine\\username): ").strip()
328
363
  mdp = input("password?: ").strip()
329
364
  interval = int(input("⏱️ Intervalle en secondes : ").strip())
330
- if alias == "''" or alias == "\"\"" or alias=="":
365
+ if alias == "''" or alias == "\"\"" or alias == "":
331
366
  alias = mail
332
367
 
333
- if 0!= enregistrer_config_owa(mail,alias,server,username,mdp,interval):
368
+ if 0 != enregistrer_config_owa(mail, alias, server, username, mdp, interval):
334
369
  print("erreur!")
335
370
 
336
- def enregistrer_config_cli_oauth2():
337
371
 
372
+ def enregistrer_config_cli_oauth2():
338
373
  print("\n📝 Écriture d’un fichier de configuration OAuth2 :")
339
-
374
+ key = get_user_key()
340
375
  client_id = input("🆔 Client ID : ").strip()
341
376
  client_secret = input("🔑 Client Secret : ").strip()
342
377
  tenant_id = input("🏢 Tenant ID (GUID Azure) : ").strip()
343
378
  user_email = input("📨 Adresse email de l'utilisateur Exchange : ").strip()
344
-
379
+ client_id_enc = xor_crypt(client_id, key)
380
+ client_secret_enc = xor_crypt(client_secret, key)
381
+ tenant_id_enc = xor_crypt(tenant_id, key)
345
382
  nom_fichier = input("💾 Nom du fichier à enregistrer (ex: config_oauth2.json) : ").strip()
383
+ choix_enregistrement = input("Voulez vous enregistrer en offuscation basique (1) ou enregistrer une clée dans "
384
+ "le trousseau (2) ?")
385
+ match choix_enregistrement:
386
+ case "1":
387
+ config = {
388
+ "client_id_enc": client_id_enc,
389
+ "client_secret_enc": client_secret_enc,
390
+ "tenant_id_enc": tenant_id_enc,
391
+ "user_email": user_email
392
+ }
393
+ case "2":
394
+ cle = f"MICROSOFT_EXCHANGE_OAUTH2 {nom_fichier}"
395
+ config = {"key": cle}
396
+ config_to_save_in_key = {
397
+ "client_id": client_id,
398
+ "client_secret": client_secret,
399
+ "tenant_id": tenant_id,
400
+ "user_email": user_email
401
+ }
402
+ s_m = secret_manager.SecretManager(cle)
403
+ s_m.store(config_to_save_in_key)
404
+
405
+
346
406
 
347
- config = {
348
- "client_id": client_id,
349
- "client_secret": client_secret,
350
- "tenant_id": tenant_id,
351
- "user_email": user_email
352
- }
353
407
 
354
408
  try:
355
409
  dossier = get_keys_dir("MICROSOFT_EXCHANGE_OAUTH2")
@@ -363,38 +417,30 @@ def enregistrer_config_cli_oauth2():
363
417
  except Exception as e:
364
418
  print(f"❌ Erreur lors de l’enregistrement : {e}")
365
419
 
366
- def lire_config_cli_oauth2(chemin_fichier):
367
- try:
368
- chemin_fichier = os.path.join(get_keys_dir("MICROSOFT_EXCHANGE_OAUTH2"), chemin_fichier)
369
- print("oauth2", chemin_fichier)
370
- with open(chemin_fichier, "r", encoding="utf-8") as f:
371
- contenu = json.load(f)
372
420
 
373
- # Retourne les infos de configuration
374
- return [
375
- contenu["client_id"],
376
- contenu["client_secret"],
377
- contenu["tenant_id"],
378
- contenu["user_email"]
379
- ]
421
+ def lire_config_cli_oauth2():
422
+ chemin_fichier = input("📄 non fichier json (pas le chemin!) JSON : ").strip()
423
+ config = lire_config_oauth2(chemin_fichier)
424
+ if config == None:
425
+ print("erreur")
426
+ print(config)
427
+
380
428
 
381
- except Exception as e:
382
- print(f"❌ Erreur lors de la lecture : {e}")
383
- return None
384
429
 
385
430
  def lecture_config_cli_owa():
386
431
  chemin_fichier = input("📄 non fichier json (pas le chemin!) JSON : ").strip()
387
432
  config = lire_config_owa(chemin_fichier)
388
433
 
389
- if config==None:
434
+ if config == None:
390
435
  print("erreur")
391
436
  print(config)
392
437
 
438
+
393
439
  def lire_config_cli_imap4_ssl():
394
440
  chemin_fichier = input("📄 non fichier json (pas le chemin!) JSON : ").strip()
395
441
  config = lire_config_imap4_ssl(chemin_fichier)
396
442
 
397
- if config==None:
443
+ if config == None:
398
444
  print("erreur")
399
445
  print(config)
400
446
 
@@ -424,6 +470,7 @@ def enregistrer_config_api(service_name, api_key, description=""):
424
470
  print(f"❌ Erreur d’enregistrement : {e}")
425
471
  return 1
426
472
 
473
+
427
474
  # Lecture + déchiffrement → dict {"service", "api_key", "description"}
428
475
  def lire_config_api(service_name):
429
476
  try:
@@ -448,6 +495,7 @@ def lire_config_api(service_name):
448
495
  print(f"❌ Erreur lors de la lecture : {e}")
449
496
  return None
450
497
 
498
+
451
499
  def enregistrer_config_cli_api():
452
500
  print("\n📝 Écriture d’une clé API :")
453
501
  service = input("🔖 Nom du service : ").strip()
@@ -456,6 +504,7 @@ def enregistrer_config_cli_api():
456
504
  if 0 != enregistrer_config_api(service, api_key, desc):
457
505
  print("erreur!")
458
506
 
507
+
459
508
  def lire_config_cli_api(service=""):
460
509
  if service == "":
461
510
  service = input("🔖 Nom du service : ").strip()
@@ -474,15 +523,14 @@ def lire_config_cli_api(service=""):
474
523
  return None
475
524
 
476
525
 
477
-
478
526
  # Gestion d’éléments de nxp (DOSSIER_NODE_ID, SERVEUR, USERNAME, PASSWORD) (HARD dossier aait_store/keys)
479
527
 
480
528
  def enregistrer_config_nxp(
481
- dossier_node_id: str,
482
- serveur: str,
483
- username: str,
484
- password: str,
485
- description: str = ""
529
+ dossier_node_id: str,
530
+ serveur: str,
531
+ username: str,
532
+ password: str,
533
+ description: str = ""
486
534
  ) -> int:
487
535
  try:
488
536
  key = get_user_key()
@@ -507,6 +555,7 @@ def enregistrer_config_nxp(
507
555
  print(f"❌ Erreur d’enregistrement : {e}")
508
556
  return 1
509
557
 
558
+
510
559
  def lire_config_nxp(serveur: str) -> dict | None:
511
560
  try:
512
561
  chemin = os.path.join(get_keys_dir("NXP"), f"{serveur}.json") # ⬅️ même logique
@@ -530,6 +579,7 @@ def lire_config_nxp(serveur: str) -> dict | None:
530
579
  print(f"❌ Erreur de lecture : {e}")
531
580
  return None
532
581
 
582
+
533
583
  def enregistrer_config_cli_nxp():
534
584
  print("\n📝 Écriture d’une connexion nxp :")
535
585
  dossier_node_id = input("📦 DOSSIER_NODE_ID : ").strip()
@@ -545,8 +595,9 @@ def enregistrer_config_cli_nxp():
545
595
  description
546
596
  )
547
597
 
598
+
548
599
  def lire_config_cli_nxp():
549
- serveur = input("🌐 SERVEUR : ").strip() # ⬅️ on demande le serveur
600
+ serveur = input("🌐 SERVEUR : ").strip() # ⬅️ on demande le serveur
550
601
  cfg = lire_config_nxp(serveur)
551
602
  if cfg is None:
552
603
  print("erreur")
@@ -572,8 +623,9 @@ if __name__ == "__main__":
572
623
  print("10) Déchiffrer fichier Microsoft Exchange (OAuth2)")
573
624
  print("11) Écrire fichier Microsoft Exchange (OWA) [SECURE]")
574
625
  print("12) Déchiffrer fichier Microsoft Exchange (OWA) [SECURE]")
626
+ print("14) ")
575
627
 
576
- choix = input("👉 Que faire ? [1-12] : ").strip()
628
+ choix = input("👉 Que faire ? [1-14] : ").strip()
577
629
 
578
630
  if choix == "1":
579
631
  enregistrer_config_cli_imap4_ssl()
@@ -587,13 +639,13 @@ if __name__ == "__main__":
587
639
  enregistrer_config_cli_nxp()
588
640
  elif choix == "6":
589
641
  lire_config_cli_nxp()
590
- elif choix=="7":
642
+ elif choix == "7":
591
643
  enregistrer_config_cli_owa()
592
- elif choix=="8":
644
+ elif choix == "8":
593
645
  lecture_config_cli_owa()
594
- elif choix=="9":
646
+ elif choix == "9":
595
647
  enregistrer_config_cli_oauth2()
596
- elif choix=="10":
648
+ elif choix == "10":
597
649
  lire_config_cli_oauth2()
598
650
  elif choix == "11":
599
651
  enregistrer_config_cli_owa_secure()
@@ -603,6 +655,3 @@ if __name__ == "__main__":
603
655
 
604
656
  else:
605
657
  print("❌ Choix invalide. Réessayez.\n")
606
-
607
-
608
-