dn53 commited on
Commit ·
c18dddf
1
Parent(s): 131b347
Update API to correctly register blueprints for evidence and login
Browse filesRefactor blueprint registration in app.py to use '/api' prefix for evidence_bp, login_bp, and syslog_bp. Modify api/evidence.py to instantiate Attestation and UploadSession objects using attribute assignment instead of dictionary-like access.
Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 13d753dc-bbfa-446f-bcd5-3d5325a591ad
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/2fb4ea93-ac3a-4c8e-a374-bb86029c18ef/13d753dc-bbfa-446f-bcd5-3d5325a591ad/dmlZHLS
- api/evidence.py +28 -30
- app.py +3 -3
api/evidence.py
CHANGED
|
@@ -154,38 +154,36 @@ def create_attestation():
|
|
| 154 |
upload_info = storage.generate_upload_url(file_name, content_type, session_id)
|
| 155 |
|
| 156 |
# Create new attestation in pending state
|
| 157 |
-
attestation = Attestation(
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
)
|
| 179 |
|
| 180 |
# Create upload session
|
| 181 |
-
upload_session = UploadSession(
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
)
|
| 189 |
|
| 190 |
db.session.add(attestation)
|
| 191 |
db.session.add(upload_session)
|
|
|
|
| 154 |
upload_info = storage.generate_upload_url(file_name, content_type, session_id)
|
| 155 |
|
| 156 |
# Create new attestation in pending state
|
| 157 |
+
attestation = Attestation()
|
| 158 |
+
attestation.key = str(uuid.uuid4())
|
| 159 |
+
attestation.target_name = context.get('target_name', 'unknown')
|
| 160 |
+
attestation.target_type = context.get('target_type', 'unknown')
|
| 161 |
+
attestation.content_type = content_type
|
| 162 |
+
attestation.context_type = data.get('context_type', 'application/json')
|
| 163 |
+
attestation.tool = context.get('tool')
|
| 164 |
+
attestation.sig_status = data.get('sig_status', 'unsigned')
|
| 165 |
+
attestation.deliverable = data.get('deliverable', False)
|
| 166 |
+
attestation.product_key = product_key
|
| 167 |
+
attestation.product_version = product_version
|
| 168 |
+
attestation.labels = labels
|
| 169 |
+
attestation.storage_path = upload_info['storage_path']
|
| 170 |
+
attestation.storage_url = None # Will be set when upload is finished
|
| 171 |
+
attestation.file_size = None # Will be set when upload is finished
|
| 172 |
+
attestation.context = context
|
| 173 |
+
attestation.user_id = current_user_id
|
| 174 |
+
attestation.team_id = data.get('team_id')
|
| 175 |
+
attestation.job_ids = data.get('job_ids', [])
|
| 176 |
+
attestation.pipeline_run = data.get('pipeline_run')
|
| 177 |
+
attestation.upload_pending = True # Mark as pending upload
|
|
|
|
| 178 |
|
| 179 |
# Create upload session
|
| 180 |
+
upload_session = UploadSession()
|
| 181 |
+
upload_session.session_id = session_id
|
| 182 |
+
upload_session.user_id = current_user_id
|
| 183 |
+
upload_session.status = 'pending'
|
| 184 |
+
upload_session.file_name = file_name
|
| 185 |
+
upload_session.upload_url = upload_info['upload_url']
|
| 186 |
+
upload_session.storage_path = upload_info['storage_path']
|
|
|
|
| 187 |
|
| 188 |
db.session.add(attestation)
|
| 189 |
db.session.add(upload_session)
|
app.py
CHANGED
|
@@ -53,7 +53,7 @@ with app.app_context():
|
|
| 53 |
from api.syslog import syslog_bp
|
| 54 |
from web.routes import web_bp
|
| 55 |
|
| 56 |
-
app.register_blueprint(evidence_bp, url_prefix='/')
|
| 57 |
-
app.register_blueprint(login_bp, url_prefix='/
|
| 58 |
-
app.register_blueprint(syslog_bp, url_prefix='/')
|
| 59 |
app.register_blueprint(web_bp)
|
|
|
|
| 53 |
from api.syslog import syslog_bp
|
| 54 |
from web.routes import web_bp
|
| 55 |
|
| 56 |
+
app.register_blueprint(evidence_bp, url_prefix='/api')
|
| 57 |
+
app.register_blueprint(login_bp, url_prefix='/api')
|
| 58 |
+
app.register_blueprint(syslog_bp, url_prefix='/api')
|
| 59 |
app.register_blueprint(web_bp)
|