Hostile 99% github Download

pulumi/pulumi master

“Pulumi - Infrastructure as Code in any programming language 🚀”

Python downloads and launches an unverified release archiveAccount collection path fragment

Evidence

imports os lines 1–21
1import io
2import os
3import pathlib
4import platform
5import requests
6import sys
7import shutil
8import subprocess
9import tarfile
10import tempfile
11from typing import Callable, Optional
12import zipfile
13
14
15class Config:
16 """Config collects configuration information necessary to execute build
17 tasks."""
18
19 def __init__(
20 self,
21 generated_dir: str …
GitHub release asset URL or base template lines 70–79
70:14… protoc_platforms = protoc_platforms
71 self.protoc_url = f"https://github.com/protocolbuffers/protobuf/releases/download/v{self.protoc_version}/protoc-{self.protoc_version}-{self.protoc_platforms[platform_key]}.zip"
72
73 self.protoc_gen_doc_version = protoc_gen_doc_version
74 self.protoc_gen_doc_platforms = protoc_gen_doc_platforms
75 self.protoc_gen_doc_url = f"https://github.com/pseudomuto/protoc-gen-doc/releases/download/v{self.protoc_gen_doc_version}/protoc-gen-doc_{self.protoc_gen_doc_version}_{self.protoc_gen_doc_platforms[platform_key]}.tar.gz"
76
77 self.proto_path = pathlib.Path(proto_path).resolve()
78 self.proto_files = {
79 …
Python archive extractall call lines 90–130
90:7… "Returns a key representing the current platform for use in configuration."""
91
92 uname = platform.uname()
93 platform_key = f"{uname.system}_{uname.machine}"
94 return platform_key
95
96
97def ensure_proto(config: Config) -> None:
98 """Ensures that Protobuf tools such as `protoc` and `protoc-gen-doc` are
99 installed."""
100
101 shutil.rmtree(config.proto_tools_dir, ignore_errors=True)
102 os.makedirs(config.proto_tools_dir, exist_ok=True)
103
104 with tempfile.TemporaryDirectory() as tmpdir:
105 with requests.get(
106 config.protoc_url, stream=True
107 ) as protoc_response, zipfile.ZipFile(
108 io.BytesIO(protoc_response.content)
109 ) as protoc_zip:
110 protoc_zip.extractall(path=tmpdir)
111
112 shutil.move(f"{tmpdir}/bin/protoc", config.protoc)
113 shutil.move(f"{tmpdir}/include", config.proto_tools_dir)
114 os.chmod(config.protoc, 0o755)
115
116 with requests.get(
117 config.protoc_gen_doc_url, stream=True
118 ) as protoc_gen_doc_response, tarfile.open(
119 fileobj=protoc_gen_doc_response.raw, mode="r:gz"
120 ) as protoc_gen_doc_tar:
121 protoc_gen_doc_tar.extractall(path=tmpdir)
122
123 shutil.move(f"{tmpdir}/protoc-gen-doc", config.protoc_gen_doc)
124 os.chmod(config.protoc_gen_doc, 0o755)
125
126
⋯4 lines
Calls subprocess.run to launch a process lines 147–154
147:8… f"{config.proto_path/file}",
148 ]
149 subprocess.run(args, check=True)
150
151
152TARGETS: dict[str, Callable[[Config], None]] = {
153 "ensure-proto": ensure_proto,
154 "generate-proto": ge …
Python not-in membership check lines 159–170
159:5… """The main program entry point."""
160
161 if len(sys.argv) < 2:
162 usage()
163
164 target = sys.argv[1]
165 if target not in TARGETS:
166 usage(f"unknown target '{target}'")
167
168 config = Config(
169 generated_dir="_generated",
170 tools_dir="_tools …

No evidence locations were recorded for this file. Raw result

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.