peass-ng/PEASS-ng · error · Exception
Variable '{var}' in module {path} is imported from itself
Error message
Variable '{var}' in module {path} is imported from itself What it means
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.
Source
Thrown at linPEAS/builder/src/linpeasModule.py:197
if func not in self.sh_code and func not in self.initial_functions and not "peass{" in self.sh_code:
raise Exception(f"Used function '{func}' in module {path} doesn't exist in the module code")
for var in self.global_variables:
if var not in self.sh_code and not "peass{" in self.sh_code:
raise Exception(f"Used variable '{var}' in module {path} doesn't exist in the module code")
for var in self.generated_global_variables:
if var not in self.sh_code:
raise Exception(f"Generated variable '{var}' in module {path} doesn't exist in the module code")
# Check for funcs and vars imported from itself
for func in self.defined_funcs:
if func in self.functions_used:
raise Exception(f"Function '{func}' in module {path} is imported from itself")
for var in self.global_variables:
if var in self.generated_global_variables:
raise Exception(f"Variable '{var}' in module {path} is imported from itself")
# Check if all variables are correctly defined
linux_global_vars = [
"OPTARG",
"PID",
"PPID",
"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",
"AWS_LAMBDA_RUNTIME_API",
"ECS_CONTAINER_METADATA_URI",
"ECS_CONTAINER_METADATA_URI_v4",
"IDENTITY_ENDPOINT",
"IDENTITY_HEADER",
"KUBERNETES_SERVICE_PORT_HTTPS",
"KUBERNETES_SERVICE_HOST"
]
main_base = None
# Base global variables don't need to be definedView on GitHub (pinned to 53fb989abc)
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
Example fix
# before # Global Variables: PSTORAGE_CRON_FILES, AWS_KEY # Generated Global Variables: AWS_KEY # after # Global Variables: PSTORAGE_CRON_FILES # Generated Global Variables: AWS_KEY
Defensive patterns
Strategy: validation
Validate before calling
meta_vars = parse_metadata("Global Variables")
gen_vars = parse_metadata("Generated Global Variables")
assert not (set(meta_vars) & set(gen_vars)), f"Duplicated in both lists: {set(meta_vars) & set(gen_vars)}" Type guard
def has_no_self_imported_vars(global_vars: list, generated_vars: list) -> bool:
return not (set(global_vars) & set(generated_vars)) Prevention
- 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
When it happens
Trigger: LinpeasModule.__init__ during build when the same variable name appears in both the '# Global Variables:' and '# Generated Global Variables:' metadata headers of one module.
Common situations: 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:'.
Related errors
- Function '{func}' in module {path} is imported from itself
- Global Variables '{', '.join(not_defined_global_vars)}' in m
- Item should be an instance of LinpeasModule
- Something falied reading PEASS script from #{url_peass}
- Value cannot be null. Parameter name: path
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/b2e483fb07ecad85.
Report an issue: GitHub.