MCPcopy Index your code
hub / github.com/aboutcode-org/vulnerablecode / get_pkgs_from_obj

Method get_pkgs_from_obj

vulnerabilities/oval_parser.py:105–123  ·  view source on GitHub ↗

returns a list of all related packages nested within an OvalObject

(self, obj: OvalObject)

Source from the content-addressed store, hash-verified

103 return (obj, state)
104
105 def get_pkgs_from_obj(self, obj: OvalObject) -> List[str]:
106 """
107 returns a list of all related packages nested within
108 an OvalObject
109 """
110
111 pkg_list = []
112
113 for var in obj.element:
114 # It appears that `var_ref` is used in Ubuntu OVAL but not Debian or SUSE.
115 if var.get("var_ref"):
116 var_elem = self.oval_document.getElementByID(var.get("var_ref"))
117 comment = var_elem.element.get("comment")
118 pkg_name = re.match("'.+'", comment).group().replace("'", "")
119 pkg_list.append(pkg_name)
120 else:
121 pkg_list.append(var.text)
122
123 return pkg_list
124
125 def get_version_range_from_state(self, state: OvalState) -> Optional[str]:
126 """

Callers 3

get_dataMethod · 0.95

Calls 2

getElementByIDMethod · 0.80
getMethod · 0.45

Tested by 2