generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
bugSomething isn't workingSomething isn't workingtriageThe issue needs to be triaged.The issue needs to be triaged.
Description
Description
The class instances of type SetupJava, OracleSetupJava and GraalVMSetup do not have the attribute action_version. This is unexpected because action_version is inherited from the base class ThirdPartyAction
Steps to Reproduce
Running on commit e42408a
- Set a break point at before this line
if model.lang_name == lang_name:
For example
def find_language_setup_action(job_node: GitHubJobNode, lang_name: BuildLanguage) -> Language | None:
"""Find the step that calls a language setup GitHub Actions and return the model.
Parameters
----------
job_node: GitHubJobNode
The target GitHub Actions job node.
lang_name: BuildLanguage
The target language used in the build.
Returns
-------
Language | None
The language model for the language setup GitHub Action or None.
"""
for callee in job_node.callee:
model = callee.model
# Check if the model implements the Language protocol.
if isinstance(model, Language):
import pdb; pdb.set_trace()
if model.lang_name == lang_name:
return model
return None
- Run this command
macaron analyze -purl pkg:maven/org.apache.hugegraph/[email protected]
You will be taken into pdb
> ...//macaron/src/macaron/slsa_analyzer/ci_service/github_actions/analyzer.py(276)find_language_setup_action()
-> if model.lang_name == lang_name:
(Pdb) type(model)
<class 'macaron.slsa_analyzer.ci_service.github_actions.analyzer.SetupJava'>
(Pdb) pp(model)
*** AttributeError: 'SetupJava' object has no attribute 'action_version'
(Pdb) "action_version" in dir(SetupJava)
False
Initial investigation
This happened because of the following factors:
SetupJavainherits fromThirdPartyAction, which is a frozen dataclass.@dataclass(frozen=True) class ThirdPartyAction: """The representation for a third-party GitHub Action.""" #: The name of the GitHub Action. action_name: str #: The version of the GitHub Action. action_version: str | None SetupJavadoesn't set theaction_versionclass attribute, instead it just annotate this attribute asNoneSetupJavadefines it owns constructor, which overrides the dataclass constructors generated forThirdPartyAction.SetupJavaconstructor doesn't initializeaction_version, hence it will never exist in any class instance.- This happens for
OracleSetupJavaandGraalVMSetupwith the same reason.
Environment Information
To assist with troubleshooting, please provide the following information about your environment:
Operating System: Ubuntu 22.04
CPU architecture information: x84-64
Bash Version: version 5.1.16(1)-release
Running Macaron as a Python package.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtriageThe issue needs to be triaged.The issue needs to be triaged.