Add a new vulnerability finding
()
| 13188 | # Stash entries. |
| 13189 | try: |
| 13190 | stash_proc = subprocess.run( |
| 13191 | ['sudo', '-n', 'git', '-C', repo_path, 'stash', 'list'], |
| 13192 | check=True, capture_output=True, text=True, |
| 13193 | timeout=PWN_GIT_TIMEOUT |
| 13194 | ) |
| 13195 | stash_lines = [ln for ln in stash_proc.stdout.splitlines() if ln.strip()] |
| 13196 | git_status['stash_entries'] = len(stash_lines) |
| 13197 | git_status['has_stash'] = git_status['stash_entries'] > 0 |
| 13198 | except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e: |
| 13199 | stderr_val = getattr(e, 'stderr', None) |
| 13200 | err_msg = stderr_val.strip() if isinstance(stderr_val, str) and stderr_val else str(e) |
| 13201 | git_status['status_error'] = git_status['status_error'] or err_msg |
| 13202 | logger.warning(f"Pwn git stash list failed: {err_msg}") |
| 13203 | |
| 13204 | return jsonify({ |
| 13205 | 'installed': True, |
| 13206 | 'updates_available': commits_behind > 0, |
| 13207 | 'commits_behind': commits_behind, |
| 13208 | 'current_commit': current_commit, |
| 13209 | 'latest_commit': latest_commit, |
| 13210 | 'current_branch': current_branch, |
| 13211 | 'repo_path': repo_path, |
| 13212 | 'git_status': git_status |
| 13213 | }) |
| 13214 | |
| 13215 | except Exception as e: |
| 13216 | logger.error(f"Error in pwn_check_updates: {e}") |
| 13217 | return jsonify({'installed': True, 'error': str(e)}), 500 |
| 13218 | |
| 13219 | @app.route('/api/pwn/update', methods=['POST']) |
| 13220 | def pwn_perform_update(): |
| 13221 | """Run git pull against /opt/pwnagotchi. Does NOT touch any service.""" |
| 13222 | repo_path = PWN_REPO_PATH |
| 13223 | |
| 13224 | if not os.path.isdir(os.path.join(repo_path, '.git')): |
| 13225 | return jsonify({ |
| 13226 | 'success': False, |
| 13227 | 'error': 'Pwnagotchi is not installed at /opt/pwnagotchi' |
| 13228 | }), 400 |
| 13229 | |
| 13230 | logger.info(f"Pwn manual update requested at {repo_path}") |
| 13231 | update_result = _execute_pwn_git_update(repo_path) |
nothing calls this directly
no test coverage detected