dn53 commited on
Commit
c18dddf
·
1 Parent(s): 131b347

Update API to correctly register blueprints for evidence and login

Browse files

Refactor 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

Files changed (2) hide show
  1. api/evidence.py +28 -30
  2. 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
- key=str(uuid.uuid4()),
159
- target_name=context.get('target_name', 'unknown'),
160
- target_type=context.get('target_type', 'unknown'),
161
- content_type=content_type,
162
- context_type=data.get('context_type', 'application/json'),
163
- tool=context.get('tool'),
164
- sig_status=data.get('sig_status', 'unsigned'),
165
- deliverable=data.get('deliverable', False),
166
- product_key=product_key,
167
- product_version=product_version,
168
- labels=labels,
169
- storage_path=upload_info['storage_path'],
170
- storage_url=None, # Will be set when upload is finished
171
- file_size=None, # Will be set when upload is finished
172
- context=context,
173
- user_id=current_user_id,
174
- team_id=data.get('team_id'),
175
- job_ids=data.get('job_ids', []),
176
- pipeline_run=data.get('pipeline_run'),
177
- upload_pending=True # Mark as pending upload
178
- )
179
 
180
  # Create upload session
181
- upload_session = UploadSession(
182
- session_id=session_id,
183
- user_id=current_user_id,
184
- status='pending',
185
- file_name=file_name,
186
- upload_url=upload_info['upload_url'],
187
- storage_path=upload_info['storage_path']
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='/v1')
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)