Skip to content

feat(fault_plane): implement fault plane calculation module with data…#79

Open
totallynotdavid wants to merge 1 commit intomainfrom
rewrite-fault_plane
Open

feat(fault_plane): implement fault plane calculation module with data…#79
totallynotdavid wants to merge 1 commit intomainfrom
rewrite-fault_plane

Conversation

@totallynotdavid
Copy link
Copy Markdown
Owner

… loading and output generation

f"{m.strike:7.2f}{m.dip:7.2f}{m.rake:7.2f}"
f"{h.magnitude:7.2f} 0 0 {h.time}"
)
(out / meca_file).write_text(meca + "\n")

Check failure

Code scanning / CodeQL

Clear-text storage of sensitive information High

This expression stores
sensitive data (private)
as clear text.
This expression stores
sensitive data (private)
as clear text.
This expression stores
sensitive data (private)
as clear text.

Copilot Autofix

AI about 1 year ago

To address the issue, we will encrypt the sensitive data before writing it to the file. We will use the cryptography library, which provides robust encryption mechanisms. Specifically, we will:

  1. Generate a symmetric encryption key (or use an existing one if already managed elsewhere in the application).
  2. Encrypt the meca string using the symmetric key.
  3. Write the encrypted data to the file instead of the plain text.
  4. Ensure the decryption process is documented or implemented elsewhere if the data needs to be read back.

This fix will involve importing the necessary modules from cryptography, encrypting the meca string, and updating the file-writing logic.


Suggested changeset 2
orchestrator/modules/fault_plane.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/orchestrator/modules/fault_plane.py b/orchestrator/modules/fault_plane.py
--- a/orchestrator/modules/fault_plane.py
+++ b/orchestrator/modules/fault_plane.py
@@ -453,2 +453,4 @@
             h = self.hypo
+            from cryptography.fernet import Fernet
+
             m = self.mechanism
@@ -459,3 +461,10 @@
             )
-            (out / meca_file).write_text(meca + "\n")
+
+            # Encrypt the meca string
+            key = b'your-symmetric-key-here'  # Replace with a securely managed key
+            cipher = Fernet(key)
+            encrypted_meca = cipher.encrypt(meca.encode())
+
+            # Write the encrypted data to the file
+            (out / meca_file).write_bytes(encrypted_meca + b"\n")
 
EOF
@@ -453,2 +453,4 @@
h = self.hypo
from cryptography.fernet import Fernet

m = self.mechanism
@@ -459,3 +461,10 @@
)
(out / meca_file).write_text(meca + "\n")

# Encrypt the meca string
key = b'your-symmetric-key-here' # Replace with a securely managed key
cipher = Fernet(key)
encrypted_meca = cipher.encrypt(meca.encode())

# Write the encrypted data to the file
(out / meca_file).write_bytes(encrypted_meca + b"\n")

requirements.txt
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/requirements.txt b/requirements.txt
--- a/requirements.txt
+++ b/requirements.txt
@@ -31 +31,3 @@
 xarray==2025.3.1 ; python_version >= "3.11"
+
+cryptography==44.0.2
\ No newline at end of file
EOF
@@ -31 +31,3 @@
xarray==2025.3.1 ; python_version >= "3.11"

cryptography==44.0.2
This fix introduces these dependencies
Package Version Security advisories
cryptography (pypi) 44.0.2 None
Copilot is powered by AI and may make mistakes. Always verify output.
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