T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:134- Finding
Unsanitized Input Embedded in Executable PyMOL and ChimeraX Scripts
- Content
View full analysis
List[str]: """Generate structure loading commands.""" pdb = self.config['pdb'] lines = ["# Load structure"] # Check if PDB ID or file path if len(pdb) == 4 and pdb.isalnum() and not Path(pdb).exists(): lines.append(f"fetch {pdb}, async=0") else: lines.append(f"load {pdb}") lines.append("") return lines ``` PyMOL depth-of-field selection: ```python else: # Specific residue lines.extend([ f"# Focus on {dof_focus}", f"select dof_target, {dof_focus}", "center dof_target", "set dof_focus, 0", ]) ``` PyMOL output commands: ```python def _generate_raytrace(self) -> List[str]: """Generate ray tracing and output commands.""" resolution = self.config.get('resolution', 2400) output = self.config.get('output', 'output.png') # Change extension to .png if not already if not output.endswith('.png'): output = output.replace('.pml', '.png') return [ "# Ray tracing and output", f"set ray_trace_fog, 1", f"set ray_trace_frames, 0", f"ray {resolution}, {resolution}", f"png {output}, dpi=300", "", f'print("Rendering complete: {output}")', "", ] ``` ChimeraX structure loading: ```python def _generate_load(self) -> List[str]: """Generate structure loading commands.""" pdb = self.config['pdb'] lines = ["# Load structure"] if len(pdb) == 4 and pdb.isalnum() and not Path(pdb).exists(): lines.append(f"open {pdb}") else: lines.append(f"open {pdb}") lines.append("") return lines ``` ChimeraX selection and rendering: ```python dof_foc ...[truncated 3602 chars]- Remediation
View remediation
