Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def find_pushhead_artifacts(self, task_cache, job, tree, pushhead):
try:
taskId, artifacts = task_cache.artifacts(tree, job, pushhead)
except ValueError:
return None
urls = []
for artifact_name in self._artifact_job.find_candidate_artifacts(artifacts):
# We can easily extract the task ID from the URL. We can't easily
# extract the build ID; we use the .ini files embedded in the
# downloaded artifact for this.
url = get_artifact_url(taskId, artifact_name)
urls.append(url)
if urls:
self.log(logging.INFO, 'artifact',
{'pushhead': pushhead,
'tree': tree},
'Installing from remote pushhead {pushhead} on {tree}')
return urls
return None
def __init__(self, task_id, artifact_name):
cot = cache._download_manager.session.get(
get_artifact_url(task_id, 'public/chainOfTrust.json.asc'))
cot.raise_for_status()
digest = algorithm = None
data = {}
# The file is GPG-signed, but we don't care about validating
# that. Instead of parsing the PGP signature, we just take
# the one line we're interested in, which starts with a `{`.
for l in cot.content.splitlines():
if l.startswith('{'):
try:
data = json.loads(l)
break
except Exception:
pass
for algorithm, digest in (data.get('artifacts', {})
.get(artifact_name, {}).items()):
pass
def install_from_task(self, taskId, distdir):
artifacts = list_artifacts(taskId)
urls = []
for artifact_name in self._artifact_job.find_candidate_artifacts(artifacts):
# We can easily extract the task ID from the URL. We can't easily
# extract the build ID; we use the .ini files embedded in the
# downloaded artifact for this.
url = get_artifact_url(taskId, artifact_name)
urls.append(url)
if not urls:
raise ValueError('Task {taskId} existed, but no artifacts found!'.format(taskId=taskId))
for url in urls:
if self.install_from_url(url, distdir):
return 1
return 0
# The file is GPG-signed, but we don't care about validating
# that. Instead of parsing the PGP signature, we just take
# the one line we're interested in, which starts with a `{`.
for l in cot.content.splitlines():
if l.startswith('{'):
try:
data = json.loads(l)
break
except Exception:
pass
for algorithm, digest in (data.get('artifacts', {})
.get(artifact_name, {}).items()):
pass
name = os.path.basename(artifact_name)
artifact_url = get_artifact_url(task_id, artifact_name,
use_proxy=not artifact_name.startswith('public/'))
super(ArtifactRecord, self).__init__(
artifact_url, name,
None, digest, algorithm, unpack=True)