catocli 3.0.14__py3-none-any.whl → 3.0.22__py3-none-any.whl

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.

Potentially problematic release.


This version of catocli might be problematic. Click here for more details.

Files changed (192) hide show
  1. catocli/Utils/clidriver.py +16 -8
  2. catocli/Utils/formatter_account_metrics.py +544 -0
  3. catocli/Utils/formatter_app_stats.py +184 -0
  4. catocli/Utils/formatter_app_stats_timeseries.py +377 -0
  5. catocli/Utils/formatter_events_timeseries.py +459 -0
  6. catocli/Utils/formatter_socket_port_metrics.py +189 -0
  7. catocli/Utils/formatter_socket_port_metrics_timeseries.py +339 -0
  8. catocli/Utils/formatter_utils.py +251 -0
  9. catocli/Utils/help_formatter.py +1 -1
  10. catocli/__init__.py +1 -1
  11. catocli/clisettings.json +37 -5
  12. catocli/parsers/custom/query_eventsFeed/README.md +94 -0
  13. catocli/parsers/custom/scim/README.md +346 -0
  14. catocli/parsers/custom/scim/scim_client.py +132 -26
  15. catocli/parsers/custom/scim/scim_commands.py +14 -56
  16. catocli/parsers/customParserApiClient.py +213 -65
  17. catocli/parsers/mutation_policy/__init__.py +405 -405
  18. catocli/parsers/mutation_site/__init__.py +15 -15
  19. catocli/parsers/mutation_sites/__init__.py +15 -15
  20. catocli/parsers/query_accountMetrics/README.md +99 -9
  21. catocli/parsers/query_accountMetrics/__init__.py +6 -0
  22. catocli/parsers/query_appStats/README.md +11 -11
  23. catocli/parsers/query_appStats/__init__.py +4 -2
  24. catocli/parsers/query_appStatsTimeSeries/README.md +10 -10
  25. catocli/parsers/query_appStatsTimeSeries/__init__.py +4 -2
  26. catocli/parsers/query_auditFeed/README.md +9 -9
  27. catocli/parsers/query_events/README.md +9 -9
  28. catocli/parsers/query_eventsTimeSeries/README.md +289 -9
  29. catocli/parsers/query_eventsTimeSeries/__init__.py +6 -0
  30. catocli/parsers/query_policy/__init__.py +42 -42
  31. catocli/parsers/query_socketPortMetrics/README.md +53 -9
  32. catocli/parsers/query_socketPortMetrics/__init__.py +6 -0
  33. catocli/parsers/query_socketPortMetricsTimeSeries/README.md +92 -9
  34. catocli/parsers/query_socketPortMetricsTimeSeries/__init__.py +4 -2
  35. {catocli-3.0.14.dist-info → catocli-3.0.22.dist-info}/METADATA +1 -1
  36. {catocli-3.0.14.dist-info → catocli-3.0.22.dist-info}/RECORD +187 -183
  37. {catocli-3.0.14.dist-info → catocli-3.0.22.dist-info}/top_level.txt +0 -1
  38. models/mutation.policy.antiMalwareFileHash.addRule.json +20 -0
  39. models/mutation.policy.antiMalwareFileHash.addSection.json +103 -0
  40. models/mutation.policy.antiMalwareFileHash.createPolicyRevision.json +123 -0
  41. models/mutation.policy.antiMalwareFileHash.discardPolicyRevision.json +123 -0
  42. models/mutation.policy.antiMalwareFileHash.moveRule.json +20 -0
  43. models/mutation.policy.antiMalwareFileHash.moveSection.json +103 -0
  44. models/mutation.policy.antiMalwareFileHash.publishPolicyRevision.json +123 -0
  45. models/mutation.policy.antiMalwareFileHash.removeRule.json +20 -0
  46. models/mutation.policy.antiMalwareFileHash.removeSection.json +103 -0
  47. models/mutation.policy.antiMalwareFileHash.updatePolicy.json +123 -0
  48. models/mutation.policy.antiMalwareFileHash.updateRule.json +20 -0
  49. models/mutation.policy.antiMalwareFileHash.updateSection.json +103 -0
  50. models/mutation.policy.appTenantRestriction.addRule.json +20 -0
  51. models/mutation.policy.appTenantRestriction.addSection.json +103 -0
  52. models/mutation.policy.appTenantRestriction.createPolicyRevision.json +123 -0
  53. models/mutation.policy.appTenantRestriction.discardPolicyRevision.json +123 -0
  54. models/mutation.policy.appTenantRestriction.moveRule.json +20 -0
  55. models/mutation.policy.appTenantRestriction.moveSection.json +103 -0
  56. models/mutation.policy.appTenantRestriction.publishPolicyRevision.json +123 -0
  57. models/mutation.policy.appTenantRestriction.removeRule.json +20 -0
  58. models/mutation.policy.appTenantRestriction.removeSection.json +103 -0
  59. models/mutation.policy.appTenantRestriction.updatePolicy.json +123 -0
  60. models/mutation.policy.appTenantRestriction.updateRule.json +20 -0
  61. models/mutation.policy.appTenantRestriction.updateSection.json +103 -0
  62. models/mutation.policy.applicationControl.addRule.json +20 -0
  63. models/mutation.policy.applicationControl.addSection.json +103 -0
  64. models/mutation.policy.applicationControl.createPolicyRevision.json +123 -0
  65. models/mutation.policy.applicationControl.discardPolicyRevision.json +123 -0
  66. models/mutation.policy.applicationControl.moveRule.json +20 -0
  67. models/mutation.policy.applicationControl.moveSection.json +103 -0
  68. models/mutation.policy.applicationControl.publishPolicyRevision.json +123 -0
  69. models/mutation.policy.applicationControl.removeRule.json +20 -0
  70. models/mutation.policy.applicationControl.removeSection.json +103 -0
  71. models/mutation.policy.applicationControl.updatePolicy.json +123 -0
  72. models/mutation.policy.applicationControl.updateRule.json +20 -0
  73. models/mutation.policy.applicationControl.updateSection.json +103 -0
  74. models/mutation.policy.dynamicIpAllocation.addRule.json +20 -0
  75. models/mutation.policy.dynamicIpAllocation.addSection.json +103 -0
  76. models/mutation.policy.dynamicIpAllocation.createPolicyRevision.json +123 -0
  77. models/mutation.policy.dynamicIpAllocation.discardPolicyRevision.json +123 -0
  78. models/mutation.policy.dynamicIpAllocation.moveRule.json +20 -0
  79. models/mutation.policy.dynamicIpAllocation.moveSection.json +103 -0
  80. models/mutation.policy.dynamicIpAllocation.publishPolicyRevision.json +123 -0
  81. models/mutation.policy.dynamicIpAllocation.removeRule.json +20 -0
  82. models/mutation.policy.dynamicIpAllocation.removeSection.json +103 -0
  83. models/mutation.policy.dynamicIpAllocation.updatePolicy.json +123 -0
  84. models/mutation.policy.dynamicIpAllocation.updateRule.json +20 -0
  85. models/mutation.policy.dynamicIpAllocation.updateSection.json +103 -0
  86. models/mutation.policy.internetFirewall.addRule.json +20 -0
  87. models/mutation.policy.internetFirewall.addSection.json +103 -0
  88. models/mutation.policy.internetFirewall.createPolicyRevision.json +123 -0
  89. models/mutation.policy.internetFirewall.discardPolicyRevision.json +123 -0
  90. models/mutation.policy.internetFirewall.moveRule.json +20 -0
  91. models/mutation.policy.internetFirewall.moveSection.json +103 -0
  92. models/mutation.policy.internetFirewall.publishPolicyRevision.json +123 -0
  93. models/mutation.policy.internetFirewall.removeRule.json +20 -0
  94. models/mutation.policy.internetFirewall.removeSection.json +103 -0
  95. models/mutation.policy.internetFirewall.updatePolicy.json +123 -0
  96. models/mutation.policy.internetFirewall.updateRule.json +20 -0
  97. models/mutation.policy.internetFirewall.updateSection.json +103 -0
  98. models/mutation.policy.remotePortFwd.addRule.json +20 -0
  99. models/mutation.policy.remotePortFwd.addSection.json +103 -0
  100. models/mutation.policy.remotePortFwd.createPolicyRevision.json +123 -0
  101. models/mutation.policy.remotePortFwd.discardPolicyRevision.json +123 -0
  102. models/mutation.policy.remotePortFwd.moveRule.json +20 -0
  103. models/mutation.policy.remotePortFwd.moveSection.json +103 -0
  104. models/mutation.policy.remotePortFwd.publishPolicyRevision.json +123 -0
  105. models/mutation.policy.remotePortFwd.removeRule.json +20 -0
  106. models/mutation.policy.remotePortFwd.removeSection.json +103 -0
  107. models/mutation.policy.remotePortFwd.updatePolicy.json +123 -0
  108. models/mutation.policy.remotePortFwd.updateRule.json +20 -0
  109. models/mutation.policy.remotePortFwd.updateSection.json +103 -0
  110. models/mutation.policy.socketLan.addRule.json +40 -0
  111. models/mutation.policy.socketLan.addSection.json +103 -0
  112. models/mutation.policy.socketLan.createPolicyRevision.json +143 -0
  113. models/mutation.policy.socketLan.discardPolicyRevision.json +143 -0
  114. models/mutation.policy.socketLan.moveRule.json +40 -0
  115. models/mutation.policy.socketLan.moveSection.json +103 -0
  116. models/mutation.policy.socketLan.publishPolicyRevision.json +143 -0
  117. models/mutation.policy.socketLan.removeRule.json +40 -0
  118. models/mutation.policy.socketLan.removeSection.json +103 -0
  119. models/mutation.policy.socketLan.updatePolicy.json +143 -0
  120. models/mutation.policy.socketLan.updateRule.json +40 -0
  121. models/mutation.policy.socketLan.updateSection.json +103 -0
  122. models/mutation.policy.terminalServer.addRule.json +20 -0
  123. models/mutation.policy.terminalServer.addSection.json +103 -0
  124. models/mutation.policy.terminalServer.createPolicyRevision.json +123 -0
  125. models/mutation.policy.terminalServer.discardPolicyRevision.json +123 -0
  126. models/mutation.policy.terminalServer.moveRule.json +20 -0
  127. models/mutation.policy.terminalServer.moveSection.json +103 -0
  128. models/mutation.policy.terminalServer.publishPolicyRevision.json +123 -0
  129. models/mutation.policy.terminalServer.removeRule.json +20 -0
  130. models/mutation.policy.terminalServer.removeSection.json +103 -0
  131. models/mutation.policy.terminalServer.updatePolicy.json +123 -0
  132. models/mutation.policy.terminalServer.updateRule.json +20 -0
  133. models/mutation.policy.terminalServer.updateSection.json +103 -0
  134. models/mutation.policy.tlsInspect.addRule.json +20 -0
  135. models/mutation.policy.tlsInspect.addSection.json +103 -0
  136. models/mutation.policy.tlsInspect.createPolicyRevision.json +123 -0
  137. models/mutation.policy.tlsInspect.discardPolicyRevision.json +123 -0
  138. models/mutation.policy.tlsInspect.moveRule.json +20 -0
  139. models/mutation.policy.tlsInspect.moveSection.json +103 -0
  140. models/mutation.policy.tlsInspect.publishPolicyRevision.json +123 -0
  141. models/mutation.policy.tlsInspect.removeRule.json +20 -0
  142. models/mutation.policy.tlsInspect.removeSection.json +103 -0
  143. models/mutation.policy.tlsInspect.updatePolicy.json +123 -0
  144. models/mutation.policy.tlsInspect.updateRule.json +20 -0
  145. models/mutation.policy.tlsInspect.updateSection.json +103 -0
  146. models/mutation.policy.wanFirewall.addRule.json +20 -0
  147. models/mutation.policy.wanFirewall.addSection.json +103 -0
  148. models/mutation.policy.wanFirewall.createPolicyRevision.json +123 -0
  149. models/mutation.policy.wanFirewall.discardPolicyRevision.json +123 -0
  150. models/mutation.policy.wanFirewall.moveRule.json +20 -0
  151. models/mutation.policy.wanFirewall.moveSection.json +103 -0
  152. models/mutation.policy.wanFirewall.publishPolicyRevision.json +123 -0
  153. models/mutation.policy.wanFirewall.removeRule.json +20 -0
  154. models/mutation.policy.wanFirewall.removeSection.json +103 -0
  155. models/mutation.policy.wanFirewall.updatePolicy.json +123 -0
  156. models/mutation.policy.wanFirewall.updateRule.json +20 -0
  157. models/mutation.policy.wanFirewall.updateSection.json +103 -0
  158. models/mutation.policy.wanNetwork.addRule.json +20 -0
  159. models/mutation.policy.wanNetwork.addSection.json +103 -0
  160. models/mutation.policy.wanNetwork.createPolicyRevision.json +123 -0
  161. models/mutation.policy.wanNetwork.discardPolicyRevision.json +123 -0
  162. models/mutation.policy.wanNetwork.moveRule.json +20 -0
  163. models/mutation.policy.wanNetwork.moveSection.json +103 -0
  164. models/mutation.policy.wanNetwork.publishPolicyRevision.json +123 -0
  165. models/mutation.policy.wanNetwork.removeRule.json +20 -0
  166. models/mutation.policy.wanNetwork.removeSection.json +103 -0
  167. models/mutation.policy.wanNetwork.updatePolicy.json +123 -0
  168. models/mutation.policy.wanNetwork.updateRule.json +20 -0
  169. models/mutation.policy.wanNetwork.updateSection.json +103 -0
  170. models/mutation.xdr.analystFeedback.json +822 -87
  171. models/query.policy.antiMalwareFileHash.policy.json +123 -0
  172. models/query.policy.appTenantRestriction.policy.json +123 -0
  173. models/query.policy.applicationControl.policy.json +123 -0
  174. models/query.policy.dynamicIpAllocation.policy.json +123 -0
  175. models/query.policy.internetFirewall.policy.json +123 -0
  176. models/query.policy.remotePortFwd.policy.json +123 -0
  177. models/query.policy.socketLan.policy.json +143 -0
  178. models/query.policy.terminalServer.policy.json +123 -0
  179. models/query.policy.tlsInspect.policy.json +123 -0
  180. models/query.policy.wanFirewall.policy.json +123 -0
  181. models/query.policy.wanNetwork.policy.json +123 -0
  182. models/query.xdr.stories.json +822 -87
  183. models/query.xdr.story.json +822 -87
  184. schema/catolib.py +34 -17
  185. catocli/Utils/csv_formatter.py +0 -663
  186. scripts/catolib.py +0 -62
  187. scripts/export_if_rules_to_json.py +0 -188
  188. scripts/export_wf_rules_to_json.py +0 -111
  189. scripts/import_wf_rules_to_tfstate.py +0 -331
  190. {catocli-3.0.14.dist-info → catocli-3.0.22.dist-info}/WHEEL +0 -0
  191. {catocli-3.0.14.dist-info → catocli-3.0.22.dist-info}/entry_points.txt +0 -0
  192. {catocli-3.0.14.dist-info → catocli-3.0.22.dist-info}/licenses/LICENSE +0 -0
schema/catolib.py CHANGED
@@ -728,8 +728,16 @@ def main(args=None):
728
728
  # Print CSV output directly without JSON formatting
729
729
  print(response[0]["__csv_output__"], end='')
730
730
  else:
731
- # Standard JSON output
732
- print(json.dumps(response[0], sort_keys=True, indent=4))
731
+ # Handle different response formats more robustly
732
+ if isinstance(response, list) and len(response) > 0:
733
+ # Standard format: [data, status, headers]
734
+ print(json.dumps(response[0], sort_keys=True, indent=4))
735
+ elif isinstance(response, dict):
736
+ # Direct dict response
737
+ print(json.dumps(response, sort_keys=True, indent=4))
738
+ else:
739
+ # Fallback: print as-is
740
+ print(json.dumps(response, sort_keys=True, indent=4))
733
741
  except KeyboardInterrupt:
734
742
  print('Operation cancelled by user (Ctrl+C).')
735
743
  exit(130) # Standard exit code for SIGINT
@@ -752,9 +760,10 @@ def writeOperationParsers(catoApiSchema):
752
760
  """Write operation parsers - thread-safe implementation"""
753
761
  parserMapping = {"query":{},"mutation":{}}
754
762
 
755
- # Load settings to get CSV-supported operations
763
+ # Load settings to get format-supported operations
756
764
  settings = loadJSON("../catocli/clisettings.json")
757
765
  csv_supported_operations = settings.get("queryOperationCsvOutput", {})
766
+ format_overrides = settings.get("queryOperationDefaultFormatOverrides", {})
758
767
 
759
768
  ## Write the raw query parser ##
760
769
  cliDriverStr =f"""
@@ -825,9 +834,11 @@ def {parserName}_parse({operationType}_subparsers):
825
834
  usage=get_help("{operationType}_{operationName}"), formatter_class=CustomSubparserHelpFormatter)
826
835
  """
827
836
  if "path" in parser:
828
- # Check if this operation supports CSV output
837
+ # Check if this operation supports format overrides (CSV, etc.)
829
838
  operation_path = parserName.replace("_", ".")
830
- supports_csv = operation_path in csv_supported_operations
839
+ supports_csv = (operation_path in csv_supported_operations or
840
+ (operation_path in format_overrides and
841
+ format_overrides[operation_path].get("enabled", False)))
831
842
 
832
843
  cliDriverStr += f"""
833
844
  {parserName}_parser.add_argument('json', nargs='?', default='{{}}', help='Variables in JSON format (defaults to empty object if not provided).')
@@ -840,11 +851,17 @@ def {parserName}_parse({operationType}_subparsers):
840
851
  {parserName}_parser.add_argument('-H', '--header', action='append', dest='headers', help='Add custom headers in "Key: Value" format. Can be used multiple times.')
841
852
  {parserName}_parser.add_argument('--headers-file', dest='headers_file', help='Load headers from a file. Each line should contain a header in "Key: Value" format.')
842
853
  """
843
- # Add -f flag for CSV-supported operations
854
+ # Add format flags for operations with format overrides
844
855
  if supports_csv:
856
+ # Generate appropriate default CSV filename from operation name
857
+ # Use the full operation name instead of stripping parts to ensure clarity
858
+ default_csv_name = f"{operationName.lower()}.csv"
859
+
845
860
  cliDriverStr += f"""
846
- {parserName}_parser.add_argument('-f', '--format', choices=['json', 'csv'], default='json', help='Output format (default: json)')
847
- {parserName}_parser.add_argument('--csv-filename', dest='csv_filename', help='Override CSV file name (default: accountmetrics.csv)')
861
+
862
+ {parserName}_parser.add_argument('-f', '--format', choices=['json', 'csv'], help='Output format (default: formatted json, use -raw for original json)')
863
+ {parserName}_parser.add_argument('-raw', '--raw', dest='raw_output', action='store_true', help='Return raw/original JSON format (bypasses default formatting)')
864
+ {parserName}_parser.add_argument('--csv-filename', dest='csv_filename', help='Override CSV file name (default: {default_csv_name})')
848
865
  {parserName}_parser.add_argument('--append-timestamp', dest='append_timestamp', action='store_true', help='Append timestamp to the CSV file name')
849
866
  """
850
867
 
@@ -885,19 +902,19 @@ def generate_timeframe_examples(operation_args):
885
902
  The `timeFrame` parameter supports both relative time ranges and absolute date ranges:
886
903
 
887
904
  **Relative Time Ranges:**
888
- - `"last.PT5M"` = Previous 5 minutes
889
- - `"last.PT1H"` = Previous 1 hour
890
- - `"last.P1D"` = Previous 1 day
891
- - `"last.P14D"` = Previous 14 days
892
- - `"last.P1M"` = Previous 1 month
905
+ - "last.PT5M" = Previous 5 minutes
906
+ - "last.PT1H" = Previous 1 hour
907
+ - "last.P1D" = Previous 1 day
908
+ - "last.P14D" = Previous 14 days
909
+ - "last.P1M" = Previous 1 month
893
910
 
894
911
  **Absolute Date Ranges:**
895
912
  Format: `"utc.YYYY-MM-{DD/HH:MM:SS--DD/HH:MM:SS}"`
896
913
 
897
- - Single day: `"utc.2023-02-{28/00:00:00--28/23:59:59}"`
898
- - Multiple days: `"utc.2023-02-{25/00:00:00--28/23:59:59}"`
899
- - Specific hours: `"utc.2023-02-{28/09:00:00--28/17:00:00}"`
900
- - Across months: `"utc.2023-{01-28/00:00:00--02-03/23:59:59}"`
914
+ - Single day: "utc.2023-02-{28/00:00:00--28/23:59:59}"
915
+ - Multiple days: "utc.2023-02-{25/00:00:00--28/23:59:59}"
916
+ - Specific hours: "utc.2023-02-{28/09:00:00--28/17:00:00}"
917
+ - Across months: "utc.2023-{01-28/00:00:00--02-03/23:59:59}"
901
918
 
902
919
  """
903
920