regscale-cli 6.20.8.0__py3-none-any.whl → 6.20.9.1__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 regscale-cli might be problematic. Click here for more details.

regscale/_version.py CHANGED
@@ -33,7 +33,7 @@ def get_version_from_pyproject() -> str:
33
33
  return match.group(1)
34
34
  except Exception:
35
35
  pass
36
- return "6.20.8.0" # fallback version
36
+ return "6.20.9.1" # fallback version
37
37
 
38
38
 
39
39
  __version__ = get_version_from_pyproject()
@@ -399,10 +399,10 @@ class Application(metaclass=Singleton):
399
399
  if config is None:
400
400
  config = {}
401
401
  self.logger.debug(f"Provided config in _fetch_config_from_regscale is: {type(config)}")
402
- token = config.get("token") or os.getenv("REGSCALE_TOKEN")
403
- domain = config.get("domain") or os.getenv("REGSCALE_DOMAIN")
402
+ token = config.get("token", os.getenv("REGSCALE_TOKEN"))
403
+ domain = config.get("domain", os.getenv("REGSCALE_DOMAIN"))
404
404
  if domain is None or "http" not in domain or domain == self.template["domain"]:
405
- domain = self.retrieve_domain()[:-1] if self.retrieve_domain().endswith("/") else self.retrieve_domain()
405
+ domain = self.retrieve_domain().rstrip("/")
406
406
  self.logger.debug(f"domain: {domain}, token: {token}")
407
407
  if domain is not None and token is not None:
408
408
  self.logger.info(f"Fetching config from {domain}...")
@@ -416,23 +416,87 @@ class Application(metaclass=Singleton):
416
416
  },
417
417
  )
418
418
  self.logger.debug(f"status_code: {response.status_code} text: {response.text}")
419
- res_data = response.json()
420
- if config := res_data.get("cliConfig"):
421
- parsed_dict = yaml.safe_load(config)
422
- self.logger.debug(f"parsed_dict: {parsed_dict}")
423
- parsed_dict["token"] = token
424
- parsed_dict["domain"] = domain
425
- from regscale.core.app.internal.login import parse_user_id_from_jwt
426
-
427
- parsed_dict["userId"] = res_data.get("userId") or parse_user_id_from_jwt(self, token)
428
- self.logger.debug(f"Updated domain, token and userId: {parsed_dict}")
429
- self.logger.info("Successfully fetched config from RegScale.")
430
- # fill in any missing keys with the template
431
- return {**self.template, **parsed_dict}
419
+
420
+ # Get the encrypted config from the response
421
+ fetched_config = response.json()
422
+ if not fetched_config or response.text == "":
423
+ self.logger.warning("No secrets found in %s", domain)
424
+ return {}
425
+ # see if it's just a dictionary
426
+ if isinstance(fetched_config, dict):
427
+ parsed_dict = fetched_config
428
+ else:
429
+ decrypted_config = self._decrypt_config(fetched_config, token)
430
+ parsed_dict = json.loads(decrypted_config)
431
+
432
+ parsed_dict["token"] = token
433
+ parsed_dict["domain"] = domain
434
+ from regscale.core.app.internal.login import parse_user_id_from_jwt
435
+
436
+ parsed_dict["userId"] = parsed_dict.get("userId") or parse_user_id_from_jwt(self, token)
437
+ self.logger.info("Successfully fetched config from RegScale.")
438
+ # fill in any missing keys with the template
439
+ return {**self.template, **parsed_dict}
432
440
  except Exception as ex:
433
- self.logger.error("Unable to fetch config from RegScale.\n%s", ex)
441
+ self.logger.error("Unable to fetch config from RegScale.\n%s", str(ex))
434
442
  return {}
435
443
 
444
+ def _decrypt_config(self, encrypted_text: str, bearer_token: str) -> str:
445
+ """
446
+ Decrypt the configuration using AES encryption with the bearer token as key
447
+
448
+ :param str encrypted_text: Base64 encoded encrypted text
449
+ :param str bearer_token: Bearer token used as encryption key
450
+ :return: Decrypted configuration string
451
+ :rtype: str
452
+ """
453
+ import base64
454
+ import hashlib
455
+ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
456
+ from cryptography.hazmat.backends import default_backend
457
+
458
+ try:
459
+ # Convert from base64
460
+ combined = base64.b64decode(encrypted_text)
461
+
462
+ # Extract IV (first 16 bytes) and cipher text
463
+ iv = combined[:16]
464
+ cipher_text = combined[16:]
465
+
466
+ # Generate key from bearer token using SHA256
467
+ key = hashlib.sha256(bearer_token.encode()).digest()
468
+
469
+ # Create cipher
470
+ cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
471
+
472
+ # Decrypt
473
+ decryptor = cipher.decryptor()
474
+ decrypted = decryptor.update(cipher_text) + decryptor.finalize()
475
+
476
+ # Remove padding and convert to string
477
+ decoded = decrypted.decode("utf-8")
478
+ # Remove all trailing whitespace and control characters
479
+ cleaned = decoded.rstrip()
480
+ # Also remove any trailing null bytes that might remain
481
+ while cleaned.endswith("\0"):
482
+ cleaned = cleaned[:-1]
483
+ # Use regex to remove any ending backslash-like pattern and characters after it
484
+ import re
485
+
486
+ # Remove any trailing backslash followed by any characters until the end
487
+ # This handles both literal backslashes and control characters like \x0e
488
+ cleaned = re.sub(r"\\[^\\]*$", "", cleaned)
489
+ # Also remove any trailing control characters that might remain
490
+ # Avoid regex for trailing control character removal to prevent potential catastrophic backtracking.
491
+ # Instead, use rstrip with a string of control characters.
492
+ cleaned = cleaned.rstrip(
493
+ "".join([chr(i) for i in range(0x00, 0x20)]) + "".join([chr(i) for i in range(0x7F, 0xA0)])
494
+ )
495
+ return cleaned
496
+ except Exception as err:
497
+ self.logger.error("Unable to decrypt config: %s", err)
498
+ return "{}"
499
+
436
500
  def _load_config_from_click_context(self) -> Optional[dict]:
437
501
  """
438
502
  Load configuration from Click context
@@ -148,6 +148,39 @@ def sync_rapid7_insight_cloud(regscale_ssp_id: int, vuln_filter: str, scan_date:
148
148
  )
149
149
 
150
150
 
151
+ @vulnerabilities.command(name="sync_servicenow_vr")
152
+ @regscale_ssp_id()
153
+ @click.option(
154
+ "--vuln_filter",
155
+ help="Filter the vulnerabilities for the selected severity. (Options: critical, high, medium, low, info)",
156
+ required=False,
157
+ type=click.Choice(["critical", "high", "medium", "low", "info"]),
158
+ default=None,
159
+ )
160
+ @click.option(
161
+ "--scan_date",
162
+ help="The date of the scan to sync vulnerabilities from Servicenow Vr",
163
+ required=False,
164
+ type=click.DateTime(formats=["%Y-%m-%d"]),
165
+ default=None,
166
+ )
167
+ @click.option(
168
+ "--all_scans",
169
+ help="Whether to sync all vulnerabilities from Servicenow Vr",
170
+ required=False,
171
+ is_flag=True,
172
+ default=False,
173
+ )
174
+ def sync_servicenow_vr(regscale_ssp_id: int, vuln_filter: str, scan_date: datetime, all_scans: bool) -> None:
175
+ """Sync Vulnerabilities from Servicenow Vr to RegScale."""
176
+ from regscale.models.integration_models.synqly_models.connectors import Vulnerabilities
177
+
178
+ vulnerabilities_servicenow_vr = Vulnerabilities("servicenow_vr")
179
+ vulnerabilities_servicenow_vr.run_sync(
180
+ regscale_ssp_id=regscale_ssp_id, vuln_filter=vuln_filter, scan_date=scan_date, all_scans=all_scans
181
+ )
182
+
183
+
151
184
  @vulnerabilities.command(name="sync_tanium_cloud")
152
185
  @regscale_ssp_id()
153
186
  @click.option(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "title": "CISA Catalog of Known Exploited Vulnerabilities",
3
- "catalogVersion": "2025.07.28",
4
- "dateReleased": "2025-07-28T14:00:14.6746Z",
3
+ "catalogVersion": "2025.07.29",
4
+ "dateReleased": "2025-07-29T12:46:00.2038Z",
5
5
  "count": 1391,
6
6
  "vulnerabilities": [
7
7
  {
@@ -115,8 +115,8 @@
115
115
  "product": "SharePoint",
116
116
  "vulnerabilityName": "Microsoft SharePoint Code Injection Vulnerability",
117
117
  "dateAdded": "2025-07-22",
118
- "shortDescription": "Microsoft SharePoint contains a code injection vulnerability that could allow an authorized attacker to execute code over a network. This vulnerability could be chained with CVE-2025-49706. The update for CVE-2025-53770 includes more robust protections than the update for CVE-2025-49704.",
119
- "requiredAction": "CISA recommends disconnecting public-facing versions of SharePoint Server that have reached their end-of-life (EOL) or end-of-service (EOS). For example, SharePoint Server 2013 and earlier versions are end-of-life and should be discontinued if still in use. For supported versions, please follow the mitigations according to CISA and vendor instructions. Adhere to the applicable BOD 22-01 guidance for cloud services or discontinue use of the product if mitigations are not available.",
118
+ "shortDescription": "Microsoft SharePoint contains a code injection vulnerability that could allow an authorized attacker to execute code over a network. This vulnerability could be chained with CVE-2025-49706. CVE-2025-53770 is a patch bypass for CVE-2025-49704, and the updates for CVE-2025-53770 include more robust protection than those for CVE-2025-49704.",
119
+ "requiredAction": "Disconnect public-facing versions of SharePoint Server that have reached their end-of-life (EOL) or end-of-service (EOS) to include SharePoint Server 2013 and earlier versions. For supported versions, please follow the mitigations according to CISA (URL listed below in Notes) and vendor instructions (URL listed below in Notes). Adhere to the applicable BOD 22-01 guidance for cloud services or discontinue use of the product if mitigations are not available.",
120
120
  "dueDate": "2025-07-23",
121
121
  "knownRansomwareCampaignUse": "Known",
122
122
  "notes": "CISA Mitigation Instructions: https:\/\/www.cisa.gov\/news-events\/alerts\/2025\/07\/20\/microsoft-releases-guidance-exploitation-sharepoint-vulnerability-cve-2025-53770; https:\/\/www.microsoft.com\/en-us\/security\/blog\/2025\/07\/22\/disrupting-active-exploitation-of-on-premises-sharepoint-vulnerabilities\/ ; https:\/\/msrc.microsoft.com\/update-guide\/vulnerability\/CVE-2025-49704 ; https:\/\/nvd.nist.gov\/vuln\/detail\/CVE-2025-49704",
@@ -130,8 +130,8 @@
130
130
  "product": "SharePoint",
131
131
  "vulnerabilityName": "Microsoft SharePoint Improper Authentication Vulnerability",
132
132
  "dateAdded": "2025-07-22",
133
- "shortDescription": "Microsoft SharePoint contains an improper authentication vulnerability that allows an authorized attacker to perform spoofing over a network. Successfully exploitation could allow an attacker to view sensitive information and make some changes to disclosed information. This vulnerability could be chained with CVE-2025-49704. The update for CVE-2025-53771 includes more robust protections than the update for CVE-2025-49706.",
134
- "requiredAction": "CISA recommends disconnecting public-facing versions of SharePoint Server that have reached their end-of-life (EOL) or end-of-service (EOS). For example, SharePoint Server 2013 and earlier versions are end-of-life and should be discontinued if still in use. For supported versions, please follow the mitigations according to CISA and vendor instructions. Adhere to the applicable BOD 22-01 guidance for cloud services or discontinue use of the product if mitigations are not available.",
133
+ "shortDescription": "Microsoft SharePoint contains an improper authentication vulnerability that allows an authorized attacker to perform spoofing over a network. Successfully exploitation could allow an attacker to view sensitive information and make some changes to disclosed information. This vulnerability could be chained with CVE-2025-49704. CVE-2025-53771 is a patch bypass for CVE-2025-49706, and the updates for CVE-2025-53771 include more robust protection than those for CVE-2025-49706.",
134
+ "requiredAction": "Disconnect public-facing versions of SharePoint Server that have reached their end-of-life (EOL) or end-of-service (EOS) to include SharePoint Server 2013 and earlier versions. For supported versions, please follow the mitigations according to CISA (URL listed below in Notes) and vendor instructions (URL listed below in Notes). Adhere to the applicable BOD 22-01 guidance for cloud services or discontinue use of the product if mitigations are not available.",
135
135
  "dueDate": "2025-07-23",
136
136
  "knownRansomwareCampaignUse": "Known",
137
137
  "notes": "CISA Mitigation Instructions: https:\/\/www.cisa.gov\/news-events\/alerts\/2025\/07\/20\/microsoft-releases-guidance-exploitation-sharepoint-vulnerability-cve-2025-53770 ; https:\/\/www.microsoft.com\/en-us\/security\/blog\/2025\/07\/22\/disrupting-active-exploitation-of-on-premises-sharepoint-vulnerabilities\/ ; https:\/\/msrc.microsoft.com\/update-guide\/vulnerability\/CVE-2025-49706 ; https:\/\/nvd.nist.gov\/vuln\/detail\/CVE-2025-49706",
@@ -145,8 +145,8 @@
145
145
  "product": "SharePoint",
146
146
  "vulnerabilityName": "Microsoft SharePoint Deserialization of Untrusted Data Vulnerability",
147
147
  "dateAdded": "2025-07-20",
148
- "shortDescription": "Microsoft SharePoint Server on-premises contains a deserialization of untrusted data vulnerability that could allow an unauthorized attacker to execute code over a network.",
149
- "requiredAction": "CISA recommends configuring AMSI integration in SharePoint and deploying Defender AV on all SharePoint servers. If AMSI cannot be enabled, CISA recommends disconnecting affected products that are public-facing on the internet from service until official mitigations are available. Once mitigations are provided, apply them according to CISA and vendor instructions. Follow the applicable BOD 22-01 guidance for cloud services or discontinue use of the product if mitigations are not available. ",
148
+ "shortDescription": "Microsoft SharePoint Server on-premises contains a deserialization of untrusted data vulnerability that could allow an unauthorized attacker to execute code over a network. This vulnerability could be chained with CVE-2025-53771. CVE-2025-53770 is a patch bypass for CVE-2025-49704, and the updates for CVE-2025-53770 include more robust protection than those for CVE-2025-49704.",
149
+ "requiredAction": "Disconnect public-facing versions of SharePoint Server that have reached their end-of-life (EOL) or end-of-service (EOS) to include SharePoint Server 2013 and earlier versions. For supported versions, please follow the mitigations according to CISA (URL listed below in Notes) and vendor instructions (URL listed below in Notes). Adhere to the applicable BOD 22-01 guidance for cloud services or discontinue use of the product if mitigations are not available.",
150
150
  "dueDate": "2025-07-21",
151
151
  "knownRansomwareCampaignUse": "Unknown",
152
152
  "notes": "CISA Mitigation Instructions: https:\/\/www.cisa.gov\/news-events\/alerts\/2025\/07\/20\/microsoft-releases-guidance-exploitation-sharepoint-vulnerability-cve-2025-53770; https:\/\/www.microsoft.com\/en-us\/security\/blog\/2025\/07\/22\/disrupting-active-exploitation-of-on-premises-sharepoint-vulnerabilities\/ ; https:\/\/msrc.microsoft.com\/update-guide\/vulnerability\/CVE-2025-53770 ; https:\/\/nvd.nist.gov\/vuln\/detail\/CVE-2025-53770",