Get vulnerability scan results
()
| 12913 | stash_message = payload.get('message') or f"Ragnar pwn auto stash {datetime.utcnow().isoformat()}" |
| 12914 | include_untracked = payload.get('include_untracked', True) |
| 12915 | |
| 12916 | stash_cmd = ['sudo', '-n', 'git', '-C', repo_path, 'stash', 'push'] |
| 12917 | if include_untracked: |
| 12918 | stash_cmd.append('-u') |
| 12919 | stash_cmd.extend(['-m', stash_message]) |
| 12920 | |
| 12921 | logger.info("Pwn auto stash + update requested via UI") |
| 12922 | |
| 12923 | try: |
| 12924 | stash_proc = subprocess.run( |
| 12925 | stash_cmd, capture_output=True, text=True, check=True, |
| 12926 | timeout=PWN_GIT_TIMEOUT |
| 12927 | ) |
| 12928 | except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e: |
| 12929 | if isinstance(e, subprocess.TimeoutExpired): |
| 12930 | err = f"git stash timed out after {PWN_GIT_TIMEOUT}s" |
| 12931 | else: |
| 12932 | err = (e.stderr or e.stdout or '').strip() or str(e) |
| 12933 | logger.error(f"Pwn git stash failed: {err}") |
| 12934 | return jsonify({'success': False, 'error': f'Git stash failed: {err}'}), 500 |
| 12935 | |
| 12936 | stash_stdout = (stash_proc.stdout.strip() or stash_proc.stderr.strip() or '') |
| 12937 | stash_created = 'No local changes to save' not in stash_stdout |
| 12938 | stash_ref = 'stash@{0}' if stash_created else None |
| 12939 | |
| 12940 | if stash_created: |
| 12941 | logger.info(f"Pwn local changes stashed as {stash_ref}") |
| 12942 | else: |
| 12943 | logger.info("Pwn auto stash requested but no local changes were found") |
| 12944 | |
| 12945 | update_result = _execute_pwn_git_update(repo_path) |
| 12946 | if not update_result['success']: |
| 12947 | logger.error("Pwn auto stash update failed; stash preserved for manual recovery") |
| 12948 | return jsonify({ |
| 12949 | 'success': False, |
| 12950 | 'error': update_result['error'] or 'Unknown error during git pull', |
| 12951 | 'warnings': update_result['warnings'], |
| 12952 | 'local_changes_preserved': stash_created |
| 12953 | }), 500 |
| 12954 | |
| 12955 | if stash_created and stash_ref: |
| 12956 | try: |
| 12957 | subprocess.run( |
| 12958 | ['sudo', '-n', 'git', '-C', repo_path, 'stash', 'drop', stash_ref], |
nothing calls this directly
no test coverage detected