Skip to content

Commit f0739c5

Browse files
Fix configuration issues
Update configuration and verification for various files. * **requirements.txt**: Remove duplicate dependencies and ensure all dependencies are listed only once. * **Dockerfile**: Update `COPY requirements.txt .` to `COPY code/requirements.txt .` and ensure the correct path for `requirements.txt` is used. * **scripts/verify_file_structure.py**: Add verification for the presence of `.env` and `config/config.py` files. * **config/config.py**: Add verification for the presence of `HUGGINGFACE_API_KEY` and `HUGGINGFACE_PROJECT_NAME` environment variables. Add logging for the values of these environment variables. * **.env**: Ensure `HUGGINGFACE_API_KEY` and `HUGGINGFACE_PROJECT_NAME` are set correctly. Add any missing environment variables required by the application. * **src/backend/app.py**: Add verification for the presence of `HUGGINGFACE_API_KEY` and `HUGGINGFACE_PROJECT_NAME` environment variables. Add logging for the values of these environment variables. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ProjectZeroDays/zero-click-exploits?shareId=XXXX-XXXX-XXXX-XXXX).
1 parent 8fd5894 commit f0739c5

File tree

6 files changed

+42
-108
lines changed

6 files changed

+42
-108
lines changed

.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# Placeholder for sensitive information
22
HUGGINGFACE_API_KEY=your_huggingface_api_key_here
33
HUGGINGFACE_PROJECT_NAME=your_project_name_here
4+
5+
# Add any missing environment variables required by the application
6+
DATABASE_URL=your_database_url_here
7+
SECRET_KEY=your_secret_key_here
8+
API_KEY=your_api_key_here
9+
API_SECRET=your_api_secret_here

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV HF_API_TOKEN=${HF_API_TOKEN}
66
ENV HF_PROJECT_NAME=${HF_PROJECT_NAME}
77

88
# Install Python Dependencies
9-
COPY requirements.txt .
9+
COPY code/requirements.txt .
1010
RUN pip install --no-cache-dir -r requirements.txt
1111

1212
# Copy The Source Files
@@ -51,4 +51,4 @@ CMD ["/app/infra/error_handling.sh"]
5151
RUN test -n "$HF_API_TOKEN" || (echo "HF_API_TOKEN is not set" && exit 1)
5252
RUN test -n "$HF_PROJECT_NAME" || (echo "HF_PROJECT_NAME is not set" && exit 1)
5353
RUN test -n "$API_KEY" || (echo "API_KEY is not set" && exit 1)
54-
RUN test -n "$API_SECRET" || (echo "API_SECRET is not set" && exit 1)
54+
RUN test -n "$API_SECRET" || (echo "API_SECRET is not set" && exit 1)

config/config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class Config:
3030
API_KEY = os.environ.get('API_KEY', 'default_api_key')
3131
API_SECRET = os.environ.get('API_SECRET', 'default_api_secret')
3232

33+
# Hugging Face API Key and Project Name
34+
HUGGINGFACE_API_KEY = os.environ.get('HUGGINGFACE_API_KEY', 'default_huggingface_api_key')
35+
HUGGINGFACE_PROJECT_NAME = os.environ.get('HUGGINGFACE_PROJECT_NAME', 'default_huggingface_project_name')
36+
3337
# Verification for MFA and encryption method implementations
3438
@staticmethod
3539
def verify_security_implementations():
@@ -61,7 +65,8 @@ def log_missing_env_vars():
6165
env_vars = [
6266
'SECRET_KEY', 'DATABASE_URL', 'AI_VULNERABILITY_SCANNING_ENABLED', 'AI_EXPLOIT_MODIFICATIONS_ENABLED',
6367
'MFA_ENABLED', 'ENCRYPTION_METHOD', 'BLOCKCHAIN_LOGGING_ENABLED', 'BLOCKCHAIN_LOGGING_NODE',
64-
'ADVANCED_ENCRYPTION_METHODS', 'SECURITY_AUDITS_ENABLED', 'PENETRATION_TESTING_ENABLED', 'API_KEY', 'API_SECRET'
68+
'ADVANCED_ENCRYPTION_METHODS', 'SECURITY_AUDITS_ENABLED', 'PENETRATION_TESTING_ENABLED', 'API_KEY', 'API_SECRET',
69+
'HUGGINGFACE_API_KEY', 'HUGGINGFACE_PROJECT_NAME'
6570
]
6671
for var in env_vars:
6772
if not os.environ.get(var):
@@ -83,3 +88,5 @@ def log_config_values():
8388
logging.info(f"PENETRATION_TESTING_ENABLED: {Config.PENETRATION_TESTING_ENABLED}")
8489
logging.info(f"API_KEY: {Config.API_KEY}")
8590
logging.info(f"API_SECRET: {Config.API_SECRET}")
91+
logging.info(f"HUGGINGFACE_API_KEY: {Config.HUGGINGFACE_API_KEY}")
92+
logging.info(f"HUGGINGFACE_PROJECT_NAME: {Config.HUGGINGFACE_PROJECT_NAME}")

requirements.txt

Lines changed: 1 addition & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,7 @@ torch==2.2.0
1111
uvicorn==0.18.2
1212
fastapi==0.92.0
1313
gunicorn==22.0.0
14-
python-dotenv==0.21.1
15-
transformers
16-
numpy
17-
Pillow
18-
tqdm
19-
scipy
20-
huggingface_hub
21-
torchaudio
22-
pydub
23-
ffmpeg-python
24-
pytorch_lightning
25-
einops
26-
sentencepiece
27-
transformers[flax]
28-
safetensors
29-
bitsandbytes
30-
faiss-cpu
31-
nlp
32-
tokenizers
33-
webdataset
34-
gradio
35-
omegaconf
36-
dataclasses
37-
scikit-learn
38-
timm
39-
dill
40-
setproctitle
41-
typing-extensions
42-
redis
43-
flask
44-
psutil
45-
matplotlib
46-
seaborn
47-
beautifulsoup4
48-
numpydoc
49-
streamlit
50-
plotly
51-
agent-zero
52-
flask_sqlalchemy
53-
flask_migrate
54-
aiohttp
55-
validators
56-
yaml
57-
pandas
58-
scikit-image
59-
web3
14+
python-dotenv==0.21.1
6015
transformers==4.38.0
6116
numpy==1.24.2
6217
Pillow==10.3.0
@@ -105,62 +60,3 @@ web3==5.31.3
10560
pip-tools==6.4.0
10661
tkinter
10762
os
108-
subprocess
109-
re
110-
shodan
111-
python-nmap
112-
logging
113-
json
114-
requests
115-
cryptography
116-
panel
117-
torch
118-
uvicorn
119-
fastapi
120-
gunicorn
121-
python-dotenv
122-
transformers
123-
numpy
124-
Pillow
125-
tqdm
126-
scipy
127-
huggingface_hub
128-
torchaudio
129-
pydub
130-
ffmpeg-python
131-
pytorch_lightning
132-
einops
133-
sentencepiece
134-
transformers[flax]
135-
safetensors
136-
bitsandbytes
137-
faiss-cpu
138-
nlp
139-
tokenizers
140-
webdataset
141-
gradio
142-
omegaconf
143-
dataclasses
144-
scikit-learn
145-
timm
146-
dill
147-
setproctitle
148-
typing-extensions
149-
redis
150-
flask
151-
psutil
152-
matplotlib
153-
seaborn
154-
beautifulsoup4
155-
numpydoc
156-
streamlit
157-
plotly
158-
tkinter
159-
agent-zero
160-
flask_sqlalchemy
161-
flask_migrate
162-
aiohttp
163-
validators
164-
yaml
165-
pandas
166-
scikit-image

scripts/verify_file_structure.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,21 @@ def verify_config_usage():
222222
else:
223223
print(f"Method {method} in {config_file} is called in other parts of the code.")
224224

225+
def verify_env_file():
226+
if not os.path.isfile(".env"):
227+
print("File missing: .env")
228+
else:
229+
print("File .env is present.")
230+
231+
def verify_config_file():
232+
if not os.path.isfile("config/config.py"):
233+
print("File missing: config/config.py")
234+
else:
235+
print("File config/config.py is present.")
236+
225237
if __name__ == "__main__":
226238
verify_correct_placement()
227239
verify_method_calls()
228240
verify_config_usage()
241+
verify_env_file()
242+
verify_config_file()

src/backend/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
db = SQLAlchemy(app)
3636
migrate = Migrate(app, db)
3737

38+
# Verify presence of HUGGINGFACE_API_KEY and HUGGINGFACE_PROJECT_NAME environment variables
39+
if not os.environ.get('HUGGINGFACE_API_KEY'):
40+
logger.error("HUGGINGFACE_API_KEY environment variable is not set.")
41+
else:
42+
logger.info(f"HUGGINGFACE_API_KEY: {os.environ.get('HUGGINGFACE_API_KEY')}")
43+
44+
if not os.environ.get('HUGGINGFACE_PROJECT_NAME'):
45+
logger.error("HUGGINGFACE_PROJECT_NAME environment variable is not set.")
46+
else:
47+
logger.info(f"HUGGINGFACE_PROJECT_NAME: {os.environ.get('HUGGINGFACE_PROJECT_NAME')}")
48+
3849
# --- Data Models ---
3950
class TrojanServer(db.Model):
4051
id = db.Column(db.Integer, primary_key=True)

0 commit comments

Comments
 (0)