MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / archive_analyzer

Function archive_analyzer

aura/analyzers/archive.py:175–200  ·  view source on GitHub ↗

Archive analyzer that looks for suspicious entries and unpacks the archive for recursive analysis

(*, location: ScanLocation)

Source from the content-addressed store, hash-verified

173
174
175def archive_analyzer(*, location: ScanLocation) -> AnalyzerReturnType:
176 """
177 Archive analyzer that looks for suspicious entries and unpacks the archive for recursive analysis
178 """
179 if location.location.is_dir():
180 return
181 elif location.metadata.get("source") == "diff":
182 return
183
184 mime = location.metadata["mime"]
185 if mime not in SUPPORTED_MIME:
186 return
187
188 tmp_dir = tempfile.mkdtemp(prefix="aura_pkg__sandbox", suffix=os.path.basename(location.location))
189 logger.info("Extracting to: '{}' [{}]".format(tmp_dir, mime))
190
191 yield location.create_child(
192 parent=location,
193 new_location=tmp_dir,
194 cleanup=True,
195 )
196
197 try:
198 yield from extract(location=location, destination=tmp_dir)
199 except (tarfile.ReadError, zipfile.BadZipFile, EOFError) as exc:
200 yield ArchiveAnomaly.from_generic_exception(location, exc)
201
202
203def diff_archive(diff) -> AnalyzerReturnType:

Callers 1

diff_archiveFunction · 0.85

Calls 4

getMethod · 0.80
create_childMethod · 0.80
extractFunction · 0.70

Tested by

no test coverage detected