{"record":{"id":"b2e483fb07ecad85","repo":"peass-ng/PEASS-ng","slug":"variable-var-in-module-path-is-imported-from","errorCode":null,"errorMessage":"Variable '{var}' in module {path} is imported from itself","messagePattern":"Variable '(.+?)' in module (.+?) is imported from itself","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"linPEAS/builder/src/linpeasModule.py","lineNumber":197,"sourceCode":"            if func not in self.sh_code and func not in self.initial_functions and not \"peass{\" in self.sh_code:\n                raise Exception(f\"Used function '{func}' in module {path} doesn't exist in the module code\")\n        \n        for var in self.global_variables:\n            if var not in self.sh_code and not \"peass{\" in self.sh_code:\n                raise Exception(f\"Used variable '{var}' in module {path} doesn't exist in the module code\")\n        \n        for var in self.generated_global_variables:\n            if var not in self.sh_code:\n                raise Exception(f\"Generated variable '{var}' in module {path} doesn't exist in the module code\")\n        \n        # Check for funcs and vars imported from itself\n        for func in self.defined_funcs:\n            if func in self.functions_used:\n                raise Exception(f\"Function '{func}' in module {path} is imported from itself\")\n        \n        for var in self.global_variables:\n            if var in self.generated_global_variables:\n                raise Exception(f\"Variable '{var}' in module {path} is imported from itself\")\n        \n        # Check if all variables are correctly defined\n        linux_global_vars = [\n            \"OPTARG\",\n            \"PID\",\n            \"PPID\",\n            \"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI\",\n            \"AWS_LAMBDA_RUNTIME_API\",\n            \"ECS_CONTAINER_METADATA_URI\",\n            \"ECS_CONTAINER_METADATA_URI_v4\",\n            \"IDENTITY_ENDPOINT\",\n            \"IDENTITY_HEADER\",\n            \"KUBERNETES_SERVICE_PORT_HTTPS\",\n            \"KUBERNETES_SERVICE_HOST\"\n        ]\n        main_base = None\n        \n        # Base global variables don't need to be defined","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/linPEAS/builder/src/linpeasModule.py#L179-L215","documentation":"A module's '# Global Variables:' (imported/used variables) must not list a variable that the module itself declares in its '# Generated Global Variables:' metadata. The builder raises this error because a variable cannot be both produced locally and imported from elsewhere.","triggerScenarios":"LinpeasModule.__init__ during build when the same variable name appears in both the '# Global Variables:' and '# Generated Global Variables:' metadata headers of one module.","commonSituations":"Copying metadata headers between modules and leaving a generated variable in the imported list; renaming a generated variable but keeping the old name in '# Global Variables:'.","solutions":["Remove the duplicated variable name from the '# Global Variables:' metadata header","Or remove it from '# Generated Global Variables:' if it is genuinely imported, not generated","Re-run the builder to verify the module loads"],"exampleFix":"# before\n# Global Variables: PSTORAGE_CRON_FILES, AWS_KEY\n# Generated Global Variables: AWS_KEY\n# after\n# Global Variables: PSTORAGE_CRON_FILES\n# Generated Global Variables: AWS_KEY","handlingStrategy":"validation","validationCode":"meta_vars = parse_metadata(\"Global Variables\")\ngen_vars = parse_metadata(\"Generated Global Variables\")\nassert not (set(meta_vars) & set(gen_vars)), f\"Duplicated in both lists: {set(meta_vars) & set(gen_vars)}\"","typeGuard":"def has_no_self_imported_vars(global_vars: list, generated_vars: list) -> bool:\n    return not (set(global_vars) & set(generated_vars))","tryCatchPattern":null,"preventionTips":["Treat '# Global Variables:' as imports and '# Generated Global Variables:' as exports; never mix","Add a pre-commit lint that checks metadata list intersection","Copy module templates instead of hand-editing headers"],"tags":["build","metadata","validation"],"backgroundTag":"module-self-import","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}