Process a single binary file to determine its dependencies. Args: binary_path (str): Path to the binary file. Returns: tuple: A tuple containing lists of packages, special cases, and missing libraries.
(binary_path)
| 152 | print(f" - {case}") |
| 153 | |
| 154 | def process_binary(binary_path): |
| 155 | """ |
| 156 | Process a single binary file to determine its dependencies. |
| 157 | |
| 158 | Args: |
| 159 | binary_path (str): Path to the binary file. |
| 160 | |
| 161 | Returns: |
| 162 | tuple: A tuple containing lists of packages, special cases, and missing libraries. |
| 163 | """ |
| 164 | print(f"Binary: {binary_path}\n") |
| 165 | print("Libraries and their corresponding packages:") |
| 166 | packages, special_cases, missing_libraries = [], [], [] |
| 167 | |
| 168 | ldd_output = run_command(['ldd', binary_path]) |
| 169 | if ldd_output is None: |
| 170 | return packages, special_cases, missing_libraries |
| 171 | |
| 172 | for line in ldd_output.splitlines(): |
| 173 | if "=>" not in line: |
| 174 | continue |
| 175 | |
| 176 | parts = line.split('=>') |
| 177 | lib_name = parts[0].strip() |
| 178 | lib_path = parts[1].split()[0].strip() |
| 179 | lib_path = os.path.realpath(lib_path) |
| 180 | |
| 181 | if lib_path == "not": |
| 182 | missing_libraries.append(lib_name) |
| 183 | print(f"MISSING: {line.strip()}") |
| 184 | else: |
| 185 | package_info = get_package_info(lib_path) |
| 186 | if package_info: |
| 187 | print(f"{lib_path} => {package_info[1]}") |
| 188 | packages.append(package_info) |
| 189 | else: |
| 190 | special_case = f"{lib_path} is not found and might be a special case" |
| 191 | special_cases.append(special_case) |
| 192 | print(f"{lib_path} => Not found, might be a special case") |
| 193 | |
| 194 | print_summary(packages, special_cases, missing_libraries, binary_path) |
| 195 | print("-------------------------------------------") |
| 196 | return packages, special_cases, missing_libraries |
| 197 | |
| 198 | def is_elf_binary(file_path): |
| 199 | """ |
no test coverage detected