diff --git a/.github/workflows/docs-ci.yml b/.github/workflows/docs-ci.yml index 511b7c2..ada779b 100644 --- a/.github/workflows/docs-ci.yml +++ b/.github/workflows/docs-ci.yml @@ -20,9 +20,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Give permission to run scripts - run: chmod +x ./docs/scripts/doc8_style_check.sh - - name: Install Dependencies run: pip install -e .[docs] diff --git a/README.rst b/README.rst index 6cbd839..d2d0a6b 100644 --- a/README.rst +++ b/README.rst @@ -1,62 +1,8 @@ -A Simple Python Project Skeleton +Go-Inspector ================================ -This repo attempts to standardize the structure of the Python-based project's -repositories using modern Python packaging and configuration techniques. -Using this `blog post`_ as inspiration, this repository serves as the base for -all new Python projects and is mergeable in existing repositories as well. -.. _blog post: https://blog.jaraco.com/a-project-skeleton-for-python-projects/ - - -Usage -===== - -A brand new project -------------------- -.. code-block:: bash - - git init my-new-repo - cd my-new-repo - git pull git@github.com:nexB/skeleton - - # Create the new repo on GitHub, then update your remote - git remote set-url origin git@github.com:nexB/your-new-repo.git - -From here, you can make the appropriate changes to the files for your specific project. - -Update an existing project ---------------------------- -.. code-block:: bash - - cd my-existing-project - git remote add skeleton git@github.com:nexB/skeleton - git fetch skeleton - git merge skeleton/main --allow-unrelated-histories - -This is also the workflow to use when updating the skeleton files in any given repository. - -More usage instructions can be found in ``docs/skeleton-usage.rst``. - - -Release Notes -============= - -- 2023-07-18: - - Add macOS-13 job in azure-pipelines.yml - -- 2022-03-04: - - Synchronize configure and configure.bat scripts for sanity - - Update CI operating system support with latest Azure OS images - - Streamline utility scripts in etc/scripts/ to create, fetch and manage third-party dependencies - There are now fewer scripts. See etc/scripts/README.rst for details - -- 2021-09-03: - - ``configure`` now requires pinned dependencies via the use of ``requirements.txt`` and ``requirements-dev.txt`` - - ``configure`` can now accept multiple options at once - - Add utility scripts from scancode-toolkit/etc/release/ for use in generating project files - - Rename virtual environment directory from ``tmp`` to ``venv`` - - Update README.rst with instructions for generating ``requirements.txt`` and ``requirements-dev.txt``, - as well as collecting dependencies as wheels and generating ABOUT files for them. - -- 2021-05-11: - - Adopt new configure scripts from ScanCode TK that allows correct configuration of which Python version is used. +- To enable the GoReSym plugin, first you need to install goresym from https://github.com/mandiant/GoReSym/releases/download/v2.6.4/GoReSym.zip +- Unzip the GoReSym.zip, extract goresym for linux and add it in src/go_inspector/bin. +- then change it to executable ```chmod u+x src/go_inspector/bin/GoReSym_lin``` +- Install requirements and dependencies using ```make dev``` +- Use ```scancode --json-pp - --go-symbol --verbose``` to get debug symbols. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 764883d..18e4250 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,7 +11,7 @@ jobs: parameters: job_name: ubuntu20_cpython image_name: ubuntu-20.04 - python_versions: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python_versions: ['3.8', '3.9', '3.10', '3.11'] test_suites: all: venv/bin/pytest -n 2 -vvs @@ -19,46 +19,46 @@ jobs: parameters: job_name: ubuntu22_cpython image_name: ubuntu-22.04 - python_versions: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python_versions: ['3.8', '3.9', '3.10', '3.11'] test_suites: all: venv/bin/pytest -n 2 -vvs - - template: etc/ci/azure-posix.yml - parameters: - job_name: macos11_cpython - image_name: macOS-11 - python_versions: ['3.7', '3.8', '3.9', '3.10', '3.11'] - test_suites: - all: venv/bin/pytest -n 2 -vvs + # - template: etc/ci/azure-posix.yml + # parameters: + # job_name: macos11_cpython + # image_name: macOS-11 + # python_versions: ['3.8', '3.9', '3.10', '3.11'] + # test_suites: + # all: venv/bin/pytest -n 2 -vvs - - template: etc/ci/azure-posix.yml - parameters: - job_name: macos12_cpython - image_name: macOS-12 - python_versions: ['3.7', '3.8', '3.9', '3.10', '3.11'] - test_suites: - all: venv/bin/pytest -n 2 -vvs + # - template: etc/ci/azure-posix.yml + # parameters: + # job_name: macos12_cpython + # image_name: macOS-12 + # python_versions: ['3.8', '3.9', '3.10', '3.11'] + # test_suites: + # all: venv/bin/pytest -n 2 -vvs - - template: etc/ci/azure-posix.yml - parameters: - job_name: macos13_cpython - image_name: macOS-13 - python_versions: ['3.7', '3.8', '3.9', '3.10', '3.11'] - test_suites: - all: venv/bin/pytest -n 2 -vvs + # - template: etc/ci/azure-posix.yml + # parameters: + # job_name: macos13_cpython + # image_name: macOS-13 + # python_versions: ['3.8', '3.9', '3.10', '3.11'] + # test_suites: + # all: venv/bin/pytest -n 2 -vvs - - template: etc/ci/azure-win.yml - parameters: - job_name: win2019_cpython - image_name: windows-2019 - python_versions: ['3.7', '3.8', '3.9', '3.10', '3.11'] - test_suites: - all: venv\Scripts\pytest -n 2 -vvs + # - template: etc/ci/azure-win.yml + # parameters: + # job_name: win2019_cpython + # image_name: windows-2019 + # python_versions: ['3.8', '3.9', '3.10', '3.11'] + # test_suites: + # all: venv\Scripts\pytest -n 2 -vvs - - template: etc/ci/azure-win.yml - parameters: - job_name: win2022_cpython - image_name: windows-2022 - python_versions: ['3.7', '3.8', '3.9', '3.10', '3.11'] - test_suites: - all: venv\Scripts\pytest -n 2 -vvs + # - template: etc/ci/azure-win.yml + # parameters: + # job_name: win2022_cpython + # image_name: windows-2022 + # python_versions: ['3.8', '3.9', '3.10', '3.11'] + # test_suites: + # all: venv\Scripts\pytest -n 2 -vvs diff --git a/docs/Makefile b/docs/Makefile index d0c3cbf..788b039 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,6 +5,7 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build +SPHINXAUTOBUILD = sphinx-autobuild SOURCEDIR = source BUILDDIR = build @@ -14,6 +15,13 @@ help: .PHONY: help Makefile +# Run the development server using sphinx-autobuild +docs: + @echo + @echo "Starting up the docs server..." + @echo + $(SPHINXAUTOBUILD) --port 8000 --watch ${SOURCEDIR} $(SOURCEDIR) "$(BUILDDIR)/html" $(SPHINXOPTS) $(O) + # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile diff --git a/docs/make.bat b/docs/make.bat index 6247f7e..4a3c1a4 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -7,11 +7,16 @@ REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) +if "%SPHINXAUTOBUILD%" == "" ( + set SPHINXAUTOBUILD=sphinx-autobuild +) set SOURCEDIR=source set BUILDDIR=build if "%1" == "" goto help +if "%1" == "docs" goto docs + %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( echo. @@ -28,6 +33,13 @@ if errorlevel 9009 ( %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% goto end +:docs +@echo +@echo Starting up the docs server... +@echo +%SPHINXAUTOBUILD% --port 8000 --watch %SOURCEDIR% %SOURCEDIR% %BUILDDIR%\html %SPHINXOPTS% %O% +goto end + :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% diff --git a/docs/scripts/doc8_style_check.sh b/docs/scripts/doc8_style_check.sh old mode 100644 new mode 100755 diff --git a/docs/source/_static/theme_overrides.css b/docs/source/_static/theme_overrides.css index 9662d63..5863ccf 100644 --- a/docs/source/_static/theme_overrides.css +++ b/docs/source/_static/theme_overrides.css @@ -1,353 +1,26 @@ -body { - color: #000000; -} - -p { - margin-bottom: 10px; -} - -.wy-plain-list-disc, .rst-content .section ul, .rst-content .toctree-wrapper ul, article ul { - margin-bottom: 10px; -} - -.custom_header_01 { - color: #cc0000; - font-size: 22px; - font-weight: bold; - line-height: 50px; -} - -h1, h2, h3, h4, h5, h6 { - margin-bottom: 20px; - margin-top: 20px; -} - -h5 { - font-size: 18px; - color: #000000; - font-style: italic; - margin-bottom: 10px; -} - -h6 { - font-size: 15px; - color: #000000; - font-style: italic; - margin-bottom: 10px; -} - -/* custom admonitions */ -/* success */ -.custom-admonition-success .admonition-title { - color: #000000; - background: #ccffcc; - border-radius: 5px 5px 0px 0px; -} -div.custom-admonition-success.admonition { - color: #000000; - background: #ffffff; - border: solid 1px #cccccc; - border-radius: 5px; - box-shadow: 1px 1px 5px 3px #d8d8d8; - margin: 20px 0px 30px 0px; -} - -/* important */ -.custom-admonition-important .admonition-title { - color: #000000; - background: #ccffcc; - border-radius: 5px 5px 0px 0px; - border-bottom: solid 1px #000000; -} -div.custom-admonition-important.admonition { - color: #000000; - background: #ffffff; - border: solid 1px #cccccc; - border-radius: 5px; - box-shadow: 1px 1px 5px 3px #d8d8d8; - margin: 20px 0px 30px 0px; -} - -/* caution */ -.custom-admonition-caution .admonition-title { - color: #000000; - background: #ffff99; - border-radius: 5px 5px 0px 0px; - border-bottom: solid 1px #e8e8e8; -} -div.custom-admonition-caution.admonition { - color: #000000; - background: #ffffff; - border: solid 1px #cccccc; - border-radius: 5px; - box-shadow: 1px 1px 5px 3px #d8d8d8; - margin: 20px 0px 30px 0px; -} - -/* note */ -.custom-admonition-note .admonition-title { - color: #ffffff; - background: #006bb3; - border-radius: 5px 5px 0px 0px; -} -div.custom-admonition-note.admonition { - color: #000000; - background: #ffffff; - border: solid 1px #cccccc; - border-radius: 5px; - box-shadow: 1px 1px 5px 3px #d8d8d8; - margin: 20px 0px 30px 0px; -} - -/* todo */ -.custom-admonition-todo .admonition-title { - color: #000000; - background: #cce6ff; - border-radius: 5px 5px 0px 0px; - border-bottom: solid 1px #99ccff; -} -div.custom-admonition-todo.admonition { - color: #000000; - background: #ffffff; - border: solid 1px #99ccff; - border-radius: 5px; - box-shadow: 1px 1px 5px 3px #d8d8d8; - margin: 20px 0px 30px 0px; -} - -/* examples */ -.custom-admonition-examples .admonition-title { - color: #000000; - background: #ffe6cc; - border-radius: 5px 5px 0px 0px; - border-bottom: solid 1px #d8d8d8; -} -div.custom-admonition-examples.admonition { - color: #000000; - background: #ffffff; - border: solid 1px #cccccc; - border-radius: 5px; - box-shadow: 1px 1px 5px 3px #d8d8d8; - margin: 20px 0px 30px 0px; -} - +/* this is the container for the pages */ .wy-nav-content { max-width: 100%; - padding-right: 100px; - padding-left: 100px; - background-color: #f2f2f2; -} - -div.rst-content { - background-color: #ffffff; - border: solid 1px #e5e5e5; - padding: 20px 40px 20px 40px; -} - -.rst-content .guilabel { - border: 1px solid #ffff99; - background: #ffff99; - font-size: 100%; - font-weight: normal; - border-radius: 4px; - padding: 2px 0px; - margin: auto 2px; - vertical-align: middle; -} - -.rst-content kbd { - font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace; - border: solid 1px #d8d8d8; - background-color: #f5f5f5; - padding: 0px 3px; - border-radius: 3px; -} - -.wy-nav-content-wrap a { - color: #0066cc; - text-decoration: none; -} -.wy-nav-content-wrap a:hover { - color: #0099cc; - text-decoration: underline; -} - -.wy-nav-top a { - color: #ffffff; -} - -/* Based on numerous similar approaches e.g., https://github.com/readthedocs/sphinx_rtd_theme/issues/117 and https://rackerlabs.github.io/docs-rackspace/tools/rtd-tables.html -- but remove form-factor limits to enable table wrap on full-size and smallest-size form factors */ -.wy-table-responsive table td { - white-space: normal !important; -} - -.rst-content table.docutils td, -.rst-content table.docutils th { - padding: 5px 10px 5px 10px; -} -.rst-content table.docutils td p, -.rst-content table.docutils th p { - font-size: 14px; - margin-bottom: 0px; -} -.rst-content table.docutils td p cite, -.rst-content table.docutils th p cite { - font-size: 14px; - background-color: transparent; -} - -.colwidths-given th { - border: solid 1px #d8d8d8 !important; -} -.colwidths-given td { - border: solid 1px #d8d8d8 !important; -} - -/*handles single-tick inline code*/ -.wy-body-for-nav cite { - color: #000000; - background-color: transparent; - font-style: normal; - font-family: "Courier New"; - font-size: 13px; - padding: 3px 3px 3px 3px; -} - -.rst-content pre.literal-block, .rst-content div[class^="highlight"] pre, .rst-content .linenodiv pre { - font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace; - font-size: 13px; - overflow: visible; - white-space: pre-wrap; - color: #000000; -} - -.rst-content pre.literal-block, .rst-content div[class^='highlight'] { - background-color: #f8f8f8; - border: solid 1px #e8e8e8; -} - -/* This enables inline code to wrap. */ -code, .rst-content tt, .rst-content code { - white-space: pre-wrap; - padding: 2px 3px 1px; - border-radius: 3px; - font-size: 13px; - background-color: #ffffff; -} - -/* use this added class for code blocks attached to bulleted list items */ -.highlight-top-margin { - margin-top: 20px !important; -} - -/* change color of inline code block */ -span.pre { - color: #e01e5a; -} - -.wy-body-for-nav blockquote { - margin: 1em 0; - padding-left: 1em; - border-left: 4px solid #ddd; - color: #000000; -} - -/* Fix the unwanted top and bottom padding inside a nested bulleted/numbered list */ -.rst-content .section ol p, .rst-content .section ul p { - margin-bottom: 0px; -} - -/* add spacing between bullets for legibility */ -.rst-content .section ol li, .rst-content .section ul li { - margin-bottom: 5px; -} - -.rst-content .section ol li:first-child, .rst-content .section ul li:first-child { - margin-top: 5px; -} - -/* but exclude the toctree bullets */ -.rst-content .toctree-wrapper ul li, .rst-content .toctree-wrapper ul li:first-child { + padding: 0px 40px 0px 0px; margin-top: 0px; - margin-bottom: 0px; } -/* remove extra space at bottom of multine list-table cell */ -.rst-content .line-block { - margin-left: 0px; - margin-bottom: 0px; - line-height: 24px; +.wy-nav-content-wrap { + border-right: solid 1px; } -/* fix extra vertical spacing in page toctree */ -.rst-content .toctree-wrapper ul li ul, article ul li ul { - margin-top: 0; - margin-bottom: 0; -} - -/* this is used by the genindex added via layout.html (see source/_templates/) to sidebar toc */ -.reference.internal.toc-index { - color: #d9d9d9; -} - -.reference.internal.toc-index.current { - background-color: #ffffff; - color: #000000; - font-weight: bold; -} - -.toc-index-div { - border-top: solid 1px #000000; - margin-top: 10px; - padding-top: 5px; -} - -.indextable ul li { - font-size: 14px; - margin-bottom: 5px; -} - -/* The next 2 fix the poor vertical spacing in genindex.html (the alphabetized index) */ -.indextable.genindextable { - margin-bottom: 20px; -} - -div.genindex-jumpbox { - margin-bottom: 10px; -} - -/* rst image classes */ - -.clear-both { - clear: both; - } - -.float-left { - float: left; - margin-right: 20px; -} - -img { - border: solid 1px #e8e8e8; -} - -/* These are custom and need to be defined in conf.py to access in all pages, e.g., '.. role:: red' */ -.img-title { - color: #000000; - /* neither padding nor margin works for vertical spacing bc it's a span -- line-height does, sort of */ - line-height: 3.0; - font-style: italic; - font-weight: 600; -} - -.img-title-para { - color: #000000; - margin-top: 20px; - margin-bottom: 0px; - font-style: italic; - font-weight: 500; -} - -.red { - color: red; +div.rst-content { + max-width: 1300px; + border: 0; + padding: 10px 80px 10px 80px; + margin-left: 50px; +} + +@media (max-width: 768px) { + div.rst-content { + max-width: 1300px; + border: 0; + padding: 0px 10px 10px 10px; + margin-left: 0px; + } } diff --git a/docs/source/conf.py b/docs/source/conf.py index 5f6fede..7771ff0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -30,6 +30,10 @@ extensions = [ "sphinx.ext.intersphinx", "sphinx_reredirects", + "sphinx_rtd_theme", + "sphinx_rtd_dark_mode", + "sphinx.ext.extlinks", + "sphinx_copybutton", ] @@ -43,7 +47,10 @@ intersphinx_mapping = { "aboutcode": ("https://aboutcode.readthedocs.io/en/latest/", None), - "scancode-workbench": ("https://scancode-workbench.readthedocs.io/en/develop/", None), + "scancode-workbench": ( + "https://scancode-workbench.readthedocs.io/en/develop/", + None, + ), } @@ -78,7 +85,9 @@ "conf_py_path": "/docs/source/", # path in the checkout to the docs root } -html_css_files = ["_static/theme_overrides.css"] +html_css_files = [ + "theme_overrides.css", +] # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. @@ -104,6 +113,4 @@ # -- Options for LaTeX output ------------------------------------------------- -latex_elements = { - 'classoptions': ',openany,oneside' -} +latex_elements = {"classoptions": ",openany,oneside"} diff --git a/requirements.txt b/requirements.txt index e69de29..bfcedc1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +importlib-metadata==4.11.3 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index d6c7da7..2545ddf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,7 +41,16 @@ setup_requires = setuptools_scm[toml] >= 4 python_requires = >=3.7 install_requires = + plugincode + scancode-toolkit + typecode + commoncode + importlib-metadata +[options.entry_points] + +scancode_scan = + go_symbol = go_inspector.plugin:GoSymbolScannerPlugin [options.packages.find] where = src @@ -62,4 +71,7 @@ docs = sphinx-rtd-theme>=1.0.0 sphinx-reredirects >= 0.1.2 doc8>=0.11.2 + sphinx-autobuild + sphinx-rtd-dark-mode>=1.3.0 + sphinx-copybutton diff --git a/src/README.rst b/src/README.rst deleted file mode 100644 index ec651fc..0000000 --- a/src/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -Put your Python source code (and installable data) in this directory. - diff --git a/src/go_inspector/__init__.py b/src/go_inspector/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/go_inspector/bin/GoReSym_lin b/src/go_inspector/bin/GoReSym_lin new file mode 100755 index 0000000..ae7d976 Binary files /dev/null and b/src/go_inspector/bin/GoReSym_lin differ diff --git a/src/go_inspector/plugin.py b/src/go_inspector/plugin.py new file mode 100644 index 0000000..f247ade --- /dev/null +++ b/src/go_inspector/plugin.py @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# ScanCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/scancode-plugins for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + +import json +import logging +import os + +import attr +from commoncode import command +from commoncode import fileutils +from commoncode.cliutils import SCAN_GROUP +from commoncode.cliutils import PluggableCommandLineOption +from plugincode.scan import ScanPlugin +from plugincode.scan import scan_impl +from typecode import contenttype +from typecode.contenttype import get_type + +""" +Extract symbols information from source code files with ctags. +""" +LOG = logging.getLogger(__name__) + +from os.path import abspath +from os.path import dirname +from os.path import join + +""" +https://github.com/mandiant/GoReSym/archive/refs/tags/v2.6.4.tar.gz +Download this zip at: +https://github.com/mandiant/GoReSym/releases/download/v2.6.4/GoReSym.zip +Extract goresym for linux +And then change it to executable +chmod u+x src/go_inspector/bin/GoReSym_lin +""" + + +def get_goresym_location(): + curr_dir = dirname(abspath(__file__)) + return join(curr_dir, "bin", "GoReSym_lin") + + +@scan_impl +class GoSymbolScannerPlugin(ScanPlugin): + """ + Scan a Go binary for symbols using GoReSym. + """ + + resource_attributes = dict( + go_symbols=attr.ib(default=attr.Factory(dict), repr=False), + ) + + options = [ + PluggableCommandLineOption( + ("--go-symbol",), + is_flag=True, + default=False, + help="Collect Go symbols.", + help_group=SCAN_GROUP, + sort_order=100, + ), + ] + + def is_enabled(self, go_symbol, **kwargs): + return go_symbol + + def get_scanner(self, **kwargs): + return collect_and_parse_symbols + + +def is_macho(location): + """ + Return True if the file at ``location`` is macho, + otherwise False + """ + t = get_type(location) + return t.filetype_file.lower().startswith("mach-o") or t.mimetype_file.lower().startswith( + "application/x-mach-binary" + ) + + +def is_executable_binary(location): + """ + Return True if the file at ``location`` is an executable binary. + """ + + if not os.path.exists(location): + return False + + if not os.path.isfile(location): + return False + + type = contenttype.Type(location) + + if not (type.is_elf or type.is_winexe or is_macho(location=location)): + return False + + return True + + +def collect_and_parse_symbols(location, **kwargs): + """ + Run GoReSym and return a mapping of symbols of interest for the Go binary file + at ``location``. + """ + if not is_executable_binary(location): + print("Not an executable binary") + return + + goresym_args = ["-p", location] + goresym_temp_dir = fileutils.get_temp_dir() + envt = {"TMPDIR": goresym_temp_dir} + + try: + rc, stdo, err = command.execute( + cmd_loc=get_goresym_location(), + args=goresym_args, + env=envt, + to_files=True, + ) + + if rc != 0: + raise Exception(open(err).read()) + + with open(stdo) as syms: + symbols = json.load(syms) + files = symbols.get("Files") or [] + files.sort() + return dict( + go_symbols=dict(build_info=symbols.get("BuildInfo") or {}, file_paths=files or []) + ) + + finally: + fileutils.delete(goresym_temp_dir) diff --git a/tests/data/app_lin_exe b/tests/data/app_lin_exe new file mode 100755 index 0000000..8047db4 Binary files /dev/null and b/tests/data/app_lin_exe differ diff --git a/tests/data/app_mac_exe b/tests/data/app_mac_exe new file mode 100755 index 0000000..87311c8 Binary files /dev/null and b/tests/data/app_mac_exe differ diff --git a/tests/data/app_win_exe b/tests/data/app_win_exe new file mode 100755 index 0000000..2cd01b1 Binary files /dev/null and b/tests/data/app_win_exe differ diff --git a/tests/data/arm_gentoo_elf b/tests/data/arm_gentoo_elf new file mode 100644 index 0000000..434af21 Binary files /dev/null and b/tests/data/arm_gentoo_elf differ diff --git a/tests/data/gore_sym_app_lin_exe_output.json b/tests/data/gore_sym_app_lin_exe_output.json new file mode 100644 index 0000000..ada4d6a --- /dev/null +++ b/tests/data/gore_sym_app_lin_exe_output.json @@ -0,0 +1,251 @@ +{ + "go_symbols": { + "build_info": { + "GoVersion": "go1.21.7", + "Path": "command-line-arguments", + "Main": { + "Path": "", + "Version": "", + "Sum": "", + "Replace": null + }, + "Deps": null, + "Settings": [ + { + "Key": "-buildmode", + "Value": "exe" + }, + { + "Key": "-compiler", + "Value": "gc" + }, + { + "Key": "CGO_ENABLED", + "Value": "1" + }, + { + "Key": "CGO_CFLAGS", + "Value": "" + }, + { + "Key": "CGO_CPPFLAGS", + "Value": "" + }, + { + "Key": "CGO_CXXFLAGS", + "Value": "" + }, + { + "Key": "CGO_LDFLAGS", + "Value": "" + }, + { + "Key": "GOARCH", + "Value": "amd64" + }, + { + "Key": "GOOS", + "Value": "linux" + }, + { + "Key": "GOAMD64", + "Value": "v1" + } + ] + }, + "file_paths": [ + "/home/tg1999/Desktop/mini-app/main.go", + "/usr/lib/go-1.21/src/errors/errors.go", + "/usr/lib/go-1.21/src/errors/wrap.go", + "/usr/lib/go-1.21/src/fmt/format.go", + "/usr/lib/go-1.21/src/fmt/print.go", + "/usr/lib/go-1.21/src/internal/abi/abi.go", + "/usr/lib/go-1.21/src/internal/abi/type.go", + "/usr/lib/go-1.21/src/internal/abi/unsafestring_go120.go", + "/usr/lib/go-1.21/src/internal/bytealg/compare_amd64.s", + "/usr/lib/go-1.21/src/internal/bytealg/equal_amd64.s", + "/usr/lib/go-1.21/src/internal/bytealg/index_amd64.go", + "/usr/lib/go-1.21/src/internal/bytealg/indexbyte_amd64.s", + "/usr/lib/go-1.21/src/internal/cpu/cpu.go", + "/usr/lib/go-1.21/src/internal/cpu/cpu_x86.go", + "/usr/lib/go-1.21/src/internal/cpu/cpu_x86.s", + "/usr/lib/go-1.21/src/internal/fmtsort/sort.go", + "/usr/lib/go-1.21/src/internal/itoa/itoa.go", + "/usr/lib/go-1.21/src/internal/poll/errno_unix.go", + "/usr/lib/go-1.21/src/internal/poll/fd.go", + "/usr/lib/go-1.21/src/internal/poll/fd_mutex.go", + "/usr/lib/go-1.21/src/internal/poll/fd_poll_runtime.go", + "/usr/lib/go-1.21/src/internal/poll/fd_unix.go", + "/usr/lib/go-1.21/src/internal/poll/fd_unixjs.go", + "/usr/lib/go-1.21/src/internal/reflectlite/type.go", + "/usr/lib/go-1.21/src/internal/syscall/unix/fcntl_unix.go", + "/usr/lib/go-1.21/src/internal/syscall/unix/nonblocking_unix.go", + "/usr/lib/go-1.21/src/io/fs/fs.go", + "/usr/lib/go-1.21/src/math/bits/bits.go", + "/usr/lib/go-1.21/src/math/exp_amd64.go", + "/usr/lib/go-1.21/src/math/unsafe.go", + "/usr/lib/go-1.21/src/os/dir.go", + "/usr/lib/go-1.21/src/os/dir_unix.go", + "/usr/lib/go-1.21/src/os/error.go", + "/usr/lib/go-1.21/src/os/file.go", + "/usr/lib/go-1.21/src/os/file_posix.go", + "/usr/lib/go-1.21/src/os/file_unix.go", + "/usr/lib/go-1.21/src/os/path_unix.go", + "/usr/lib/go-1.21/src/os/proc.go", + "/usr/lib/go-1.21/src/path/filepath/match.go", + "/usr/lib/go-1.21/src/path/filepath/path.go", + "/usr/lib/go-1.21/src/path/filepath/path_unix.go", + "/usr/lib/go-1.21/src/reflect/abi.go", + "/usr/lib/go-1.21/src/reflect/asm_amd64.s", + "/usr/lib/go-1.21/src/reflect/float32reg_generic.go", + "/usr/lib/go-1.21/src/reflect/makefunc.go", + "/usr/lib/go-1.21/src/reflect/type.go", + "/usr/lib/go-1.21/src/reflect/value.go", + "/usr/lib/go-1.21/src/runtime/alg.go", + "/usr/lib/go-1.21/src/runtime/arena.go", + "/usr/lib/go-1.21/src/runtime/asm.s", + "/usr/lib/go-1.21/src/runtime/asm_amd64.s", + "/usr/lib/go-1.21/src/runtime/atomic_pointer.go", + "/usr/lib/go-1.21/src/runtime/cgo_mmap.go", + "/usr/lib/go-1.21/src/runtime/cgo_sigaction.go", + "/usr/lib/go-1.21/src/runtime/cgocall.go", + "/usr/lib/go-1.21/src/runtime/chan.go", + "/usr/lib/go-1.21/src/runtime/cpuflags_amd64.go", + "/usr/lib/go-1.21/src/runtime/cpuprof.go", + "/usr/lib/go-1.21/src/runtime/debug.go", + "/usr/lib/go-1.21/src/runtime/debugcall.go", + "/usr/lib/go-1.21/src/runtime/defs_linux_amd64.go", + "/usr/lib/go-1.21/src/runtime/duff_amd64.s", + "/usr/lib/go-1.21/src/runtime/env_posix.go", + "/usr/lib/go-1.21/src/runtime/error.go", + "/usr/lib/go-1.21/src/runtime/exithook.go", + "/usr/lib/go-1.21/src/runtime/extern.go", + "/usr/lib/go-1.21/src/runtime/fastlog2.go", + "/usr/lib/go-1.21/src/runtime/float.go", + "/usr/lib/go-1.21/src/runtime/hash64.go", + "/usr/lib/go-1.21/src/runtime/histogram.go", + "/usr/lib/go-1.21/src/runtime/iface.go", + "/usr/lib/go-1.21/src/runtime/internal/atomic/types.go", + "/usr/lib/go-1.21/src/runtime/internal/sys/intrinsics.go", + "/usr/lib/go-1.21/src/runtime/internal/syscall/asm_linux_amd64.s", + "/usr/lib/go-1.21/src/runtime/internal/syscall/syscall_linux.go", + "/usr/lib/go-1.21/src/runtime/lfstack.go", + "/usr/lib/go-1.21/src/runtime/lock_futex.go", + "/usr/lib/go-1.21/src/runtime/lockrank.go", + "/usr/lib/go-1.21/src/runtime/lockrank_off.go", + "/usr/lib/go-1.21/src/runtime/malloc.go", + "/usr/lib/go-1.21/src/runtime/map.go", + "/usr/lib/go-1.21/src/runtime/map_fast32.go", + "/usr/lib/go-1.21/src/runtime/map_fast64.go", + "/usr/lib/go-1.21/src/runtime/map_faststr.go", + "/usr/lib/go-1.21/src/runtime/mbarrier.go", + "/usr/lib/go-1.21/src/runtime/mbitmap.go", + "/usr/lib/go-1.21/src/runtime/mcache.go", + "/usr/lib/go-1.21/src/runtime/mcentral.go", + "/usr/lib/go-1.21/src/runtime/mcheckmark.go", + "/usr/lib/go-1.21/src/runtime/mem.go", + "/usr/lib/go-1.21/src/runtime/mem_linux.go", + "/usr/lib/go-1.21/src/runtime/memclr_amd64.s", + "/usr/lib/go-1.21/src/runtime/memmove_amd64.s", + "/usr/lib/go-1.21/src/runtime/mfinal.go", + "/usr/lib/go-1.21/src/runtime/mfixalloc.go", + "/usr/lib/go-1.21/src/runtime/mgc.go", + "/usr/lib/go-1.21/src/runtime/mgclimit.go", + "/usr/lib/go-1.21/src/runtime/mgcmark.go", + "/usr/lib/go-1.21/src/runtime/mgcpacer.go", + "/usr/lib/go-1.21/src/runtime/mgcscavenge.go", + "/usr/lib/go-1.21/src/runtime/mgcstack.go", + "/usr/lib/go-1.21/src/runtime/mgcsweep.go", + "/usr/lib/go-1.21/src/runtime/mgcwork.go", + "/usr/lib/go-1.21/src/runtime/mheap.go", + "/usr/lib/go-1.21/src/runtime/mpagealloc.go", + "/usr/lib/go-1.21/src/runtime/mpagealloc_64bit.go", + "/usr/lib/go-1.21/src/runtime/mpagecache.go", + "/usr/lib/go-1.21/src/runtime/mpallocbits.go", + "/usr/lib/go-1.21/src/runtime/mprof.go", + "/usr/lib/go-1.21/src/runtime/mranges.go", + "/usr/lib/go-1.21/src/runtime/msize.go", + "/usr/lib/go-1.21/src/runtime/mspanset.go", + "/usr/lib/go-1.21/src/runtime/mstats.go", + "/usr/lib/go-1.21/src/runtime/mwbbuf.go", + "/usr/lib/go-1.21/src/runtime/nbpipe_pipe2.go", + "/usr/lib/go-1.21/src/runtime/netpoll.go", + "/usr/lib/go-1.21/src/runtime/netpoll_epoll.go", + "/usr/lib/go-1.21/src/runtime/os_linux.go", + "/usr/lib/go-1.21/src/runtime/os_linux_generic.go", + "/usr/lib/go-1.21/src/runtime/pagetrace_off.go", + "/usr/lib/go-1.21/src/runtime/panic.go", + "/usr/lib/go-1.21/src/runtime/pinner.go", + "/usr/lib/go-1.21/src/runtime/preempt.go", + "/usr/lib/go-1.21/src/runtime/preempt_amd64.s", + "/usr/lib/go-1.21/src/runtime/print.go", + "/usr/lib/go-1.21/src/runtime/proc.go", + "/usr/lib/go-1.21/src/runtime/profbuf.go", + "/usr/lib/go-1.21/src/runtime/retry.go", + "/usr/lib/go-1.21/src/runtime/rt0_linux_amd64.s", + "/usr/lib/go-1.21/src/runtime/runtime.go", + "/usr/lib/go-1.21/src/runtime/runtime1.go", + "/usr/lib/go-1.21/src/runtime/runtime2.go", + "/usr/lib/go-1.21/src/runtime/rwmutex.go", + "/usr/lib/go-1.21/src/runtime/security_unix.go", + "/usr/lib/go-1.21/src/runtime/select.go", + "/usr/lib/go-1.21/src/runtime/sema.go", + "/usr/lib/go-1.21/src/runtime/signal_amd64.go", + "/usr/lib/go-1.21/src/runtime/signal_linux_amd64.go", + "/usr/lib/go-1.21/src/runtime/signal_unix.go", + "/usr/lib/go-1.21/src/runtime/sigqueue.go", + "/usr/lib/go-1.21/src/runtime/slice.go", + "/usr/lib/go-1.21/src/runtime/stack.go", + "/usr/lib/go-1.21/src/runtime/stkframe.go", + "/usr/lib/go-1.21/src/runtime/string.go", + "/usr/lib/go-1.21/src/runtime/stubs.go", + "/usr/lib/go-1.21/src/runtime/stubs2.go", + "/usr/lib/go-1.21/src/runtime/symtab.go", + "/usr/lib/go-1.21/src/runtime/symtabinl.go", + "/usr/lib/go-1.21/src/runtime/sys_linux_amd64.s", + "/usr/lib/go-1.21/src/runtime/sys_x86.go", + "/usr/lib/go-1.21/src/runtime/tagptr_64bit.go", + "/usr/lib/go-1.21/src/runtime/time.go", + "/usr/lib/go-1.21/src/runtime/time_linux_amd64.s", + "/usr/lib/go-1.21/src/runtime/time_nofake.go", + "/usr/lib/go-1.21/src/runtime/trace.go", + "/usr/lib/go-1.21/src/runtime/traceback.go", + "/usr/lib/go-1.21/src/runtime/type.go", + "/usr/lib/go-1.21/src/runtime/typekind.go", + "/usr/lib/go-1.21/src/runtime/unsafe.go", + "/usr/lib/go-1.21/src/runtime/utf8.go", + "/usr/lib/go-1.21/src/runtime/vdso_linux.go", + "/usr/lib/go-1.21/src/runtime/write_err.go", + "/usr/lib/go-1.21/src/sort/sort.go", + "/usr/lib/go-1.21/src/sort/zsortinterface.go", + "/usr/lib/go-1.21/src/strconv/atoi.go", + "/usr/lib/go-1.21/src/strconv/decimal.go", + "/usr/lib/go-1.21/src/strconv/ftoa.go", + "/usr/lib/go-1.21/src/strconv/ftoaryu.go", + "/usr/lib/go-1.21/src/strconv/itoa.go", + "/usr/lib/go-1.21/src/strconv/quote.go", + "/usr/lib/go-1.21/src/strings/builder.go", + "/usr/lib/go-1.21/src/strings/strings.go", + "/usr/lib/go-1.21/src/sync/atomic/type.go", + "/usr/lib/go-1.21/src/sync/atomic/value.go", + "/usr/lib/go-1.21/src/sync/map.go", + "/usr/lib/go-1.21/src/sync/mutex.go", + "/usr/lib/go-1.21/src/sync/once.go", + "/usr/lib/go-1.21/src/sync/pool.go", + "/usr/lib/go-1.21/src/sync/poolqueue.go", + "/usr/lib/go-1.21/src/sync/runtime.go", + "/usr/lib/go-1.21/src/syscall/env_unix.go", + "/usr/lib/go-1.21/src/syscall/exec_unix.go", + "/usr/lib/go-1.21/src/syscall/rlimit.go", + "/usr/lib/go-1.21/src/syscall/syscall_linux.go", + "/usr/lib/go-1.21/src/syscall/syscall_unix.go", + "/usr/lib/go-1.21/src/syscall/zsyscall_linux_amd64.go", + "/usr/lib/go-1.21/src/time/format.go", + "/usr/lib/go-1.21/src/time/time.go", + "/usr/lib/go-1.21/src/unicode/casetables.go", + "/usr/lib/go-1.21/src/unicode/tables.go", + "/usr/lib/go-1.21/src/unicode/utf8/utf8.go", + "" + ] + } + } \ No newline at end of file diff --git a/tests/data/gore_sym_app_mac_exe_output.json b/tests/data/gore_sym_app_mac_exe_output.json new file mode 100644 index 0000000..6be185c --- /dev/null +++ b/tests/data/gore_sym_app_mac_exe_output.json @@ -0,0 +1,251 @@ +{ + "go_symbols": { + "build_info": { + "GoVersion": "go1.21.7", + "Path": "command-line-arguments", + "Main": { + "Path": "", + "Version": "", + "Sum": "", + "Replace": null + }, + "Deps": null, + "Settings": [ + { + "Key": "-buildmode", + "Value": "exe" + }, + { + "Key": "-compiler", + "Value": "gc" + }, + { + "Key": "CGO_ENABLED", + "Value": "0" + }, + { + "Key": "GOARCH", + "Value": "arm64" + }, + { + "Key": "GOOS", + "Value": "darwin" + } + ] + }, + "file_paths": [ + "/home/tg1999/Desktop/mini-app/main.go", + "/usr/lib/go-1.21/src/errors/errors.go", + "/usr/lib/go-1.21/src/errors/wrap.go", + "/usr/lib/go-1.21/src/fmt/format.go", + "/usr/lib/go-1.21/src/fmt/print.go", + "/usr/lib/go-1.21/src/internal/abi/abi.go", + "/usr/lib/go-1.21/src/internal/abi/type.go", + "/usr/lib/go-1.21/src/internal/abi/unsafestring_go120.go", + "/usr/lib/go-1.21/src/internal/bytealg/compare_arm64.s", + "/usr/lib/go-1.21/src/internal/bytealg/equal_arm64.s", + "/usr/lib/go-1.21/src/internal/bytealg/index_arm64.go", + "/usr/lib/go-1.21/src/internal/bytealg/indexbyte_arm64.s", + "/usr/lib/go-1.21/src/internal/cpu/cpu.go", + "/usr/lib/go-1.21/src/internal/cpu/cpu_arm64.go", + "/usr/lib/go-1.21/src/internal/cpu/cpu_arm64_darwin.go", + "/usr/lib/go-1.21/src/internal/fmtsort/sort.go", + "/usr/lib/go-1.21/src/internal/itoa/itoa.go", + "/usr/lib/go-1.21/src/internal/poll/errno_unix.go", + "/usr/lib/go-1.21/src/internal/poll/fd.go", + "/usr/lib/go-1.21/src/internal/poll/fd_mutex.go", + "/usr/lib/go-1.21/src/internal/poll/fd_poll_runtime.go", + "/usr/lib/go-1.21/src/internal/poll/fd_unix.go", + "/usr/lib/go-1.21/src/internal/poll/fd_unixjs.go", + "/usr/lib/go-1.21/src/internal/reflectlite/type.go", + "/usr/lib/go-1.21/src/internal/syscall/unix/fcntl_unix.go", + "/usr/lib/go-1.21/src/internal/syscall/unix/nonblocking_unix.go", + "/usr/lib/go-1.21/src/internal/testlog/log.go", + "/usr/lib/go-1.21/src/io/fs/fs.go", + "/usr/lib/go-1.21/src/math/bits/bits.go", + "/usr/lib/go-1.21/src/math/unsafe.go", + "/usr/lib/go-1.21/src/os/dir.go", + "/usr/lib/go-1.21/src/os/dir_darwin.go", + "/usr/lib/go-1.21/src/os/env.go", + "/usr/lib/go-1.21/src/os/error.go", + "/usr/lib/go-1.21/src/os/executable_darwin.go", + "/usr/lib/go-1.21/src/os/file.go", + "/usr/lib/go-1.21/src/os/file_posix.go", + "/usr/lib/go-1.21/src/os/file_unix.go", + "/usr/lib/go-1.21/src/os/getwd.go", + "/usr/lib/go-1.21/src/os/path_unix.go", + "/usr/lib/go-1.21/src/os/proc.go", + "/usr/lib/go-1.21/src/os/stat_darwin.go", + "/usr/lib/go-1.21/src/os/stat_unix.go", + "/usr/lib/go-1.21/src/os/types.go", + "/usr/lib/go-1.21/src/os/types_unix.go", + "/usr/lib/go-1.21/src/path/filepath/match.go", + "/usr/lib/go-1.21/src/path/filepath/path.go", + "/usr/lib/go-1.21/src/path/filepath/path_unix.go", + "/usr/lib/go-1.21/src/reflect/abi.go", + "/usr/lib/go-1.21/src/reflect/asm_arm64.s", + "/usr/lib/go-1.21/src/reflect/float32reg_generic.go", + "/usr/lib/go-1.21/src/reflect/makefunc.go", + "/usr/lib/go-1.21/src/reflect/type.go", + "/usr/lib/go-1.21/src/reflect/value.go", + "/usr/lib/go-1.21/src/runtime/alg.go", + "/usr/lib/go-1.21/src/runtime/arena.go", + "/usr/lib/go-1.21/src/runtime/asm.s", + "/usr/lib/go-1.21/src/runtime/asm_arm64.s", + "/usr/lib/go-1.21/src/runtime/atomic_pointer.go", + "/usr/lib/go-1.21/src/runtime/cgocall.go", + "/usr/lib/go-1.21/src/runtime/chan.go", + "/usr/lib/go-1.21/src/runtime/cpuflags_arm64.go", + "/usr/lib/go-1.21/src/runtime/cpuprof.go", + "/usr/lib/go-1.21/src/runtime/debug.go", + "/usr/lib/go-1.21/src/runtime/debugcall.go", + "/usr/lib/go-1.21/src/runtime/defs_darwin_arm64.go", + "/usr/lib/go-1.21/src/runtime/duff_arm64.s", + "/usr/lib/go-1.21/src/runtime/env_posix.go", + "/usr/lib/go-1.21/src/runtime/error.go", + "/usr/lib/go-1.21/src/runtime/exithook.go", + "/usr/lib/go-1.21/src/runtime/extern.go", + "/usr/lib/go-1.21/src/runtime/fastlog2.go", + "/usr/lib/go-1.21/src/runtime/float.go", + "/usr/lib/go-1.21/src/runtime/hash64.go", + "/usr/lib/go-1.21/src/runtime/histogram.go", + "/usr/lib/go-1.21/src/runtime/iface.go", + "/usr/lib/go-1.21/src/runtime/internal/atomic/types.go", + "/usr/lib/go-1.21/src/runtime/internal/sys/intrinsics.go", + "/usr/lib/go-1.21/src/runtime/lfstack.go", + "/usr/lib/go-1.21/src/runtime/lock_sema.go", + "/usr/lib/go-1.21/src/runtime/lockrank.go", + "/usr/lib/go-1.21/src/runtime/lockrank_off.go", + "/usr/lib/go-1.21/src/runtime/malloc.go", + "/usr/lib/go-1.21/src/runtime/map.go", + "/usr/lib/go-1.21/src/runtime/map_fast32.go", + "/usr/lib/go-1.21/src/runtime/map_fast64.go", + "/usr/lib/go-1.21/src/runtime/map_faststr.go", + "/usr/lib/go-1.21/src/runtime/mbarrier.go", + "/usr/lib/go-1.21/src/runtime/mbitmap.go", + "/usr/lib/go-1.21/src/runtime/mcache.go", + "/usr/lib/go-1.21/src/runtime/mcentral.go", + "/usr/lib/go-1.21/src/runtime/mcheckmark.go", + "/usr/lib/go-1.21/src/runtime/mem.go", + "/usr/lib/go-1.21/src/runtime/mem_darwin.go", + "/usr/lib/go-1.21/src/runtime/memclr_arm64.s", + "/usr/lib/go-1.21/src/runtime/memmove_arm64.s", + "/usr/lib/go-1.21/src/runtime/mfinal.go", + "/usr/lib/go-1.21/src/runtime/mfixalloc.go", + "/usr/lib/go-1.21/src/runtime/mgc.go", + "/usr/lib/go-1.21/src/runtime/mgclimit.go", + "/usr/lib/go-1.21/src/runtime/mgcmark.go", + "/usr/lib/go-1.21/src/runtime/mgcpacer.go", + "/usr/lib/go-1.21/src/runtime/mgcscavenge.go", + "/usr/lib/go-1.21/src/runtime/mgcstack.go", + "/usr/lib/go-1.21/src/runtime/mgcsweep.go", + "/usr/lib/go-1.21/src/runtime/mgcwork.go", + "/usr/lib/go-1.21/src/runtime/mheap.go", + "/usr/lib/go-1.21/src/runtime/mpagealloc.go", + "/usr/lib/go-1.21/src/runtime/mpagealloc_64bit.go", + "/usr/lib/go-1.21/src/runtime/mpagecache.go", + "/usr/lib/go-1.21/src/runtime/mpallocbits.go", + "/usr/lib/go-1.21/src/runtime/mprof.go", + "/usr/lib/go-1.21/src/runtime/mranges.go", + "/usr/lib/go-1.21/src/runtime/msize.go", + "/usr/lib/go-1.21/src/runtime/mspanset.go", + "/usr/lib/go-1.21/src/runtime/mstats.go", + "/usr/lib/go-1.21/src/runtime/mwbbuf.go", + "/usr/lib/go-1.21/src/runtime/nbpipe_pipe.go", + "/usr/lib/go-1.21/src/runtime/netpoll.go", + "/usr/lib/go-1.21/src/runtime/netpoll_kqueue.go", + "/usr/lib/go-1.21/src/runtime/os_darwin.go", + "/usr/lib/go-1.21/src/runtime/os_darwin_arm64.go", + "/usr/lib/go-1.21/src/runtime/os_unix.go", + "/usr/lib/go-1.21/src/runtime/os_unix_nonlinux.go", + "/usr/lib/go-1.21/src/runtime/pagetrace_off.go", + "/usr/lib/go-1.21/src/runtime/panic.go", + "/usr/lib/go-1.21/src/runtime/pinner.go", + "/usr/lib/go-1.21/src/runtime/preempt.go", + "/usr/lib/go-1.21/src/runtime/preempt_arm64.s", + "/usr/lib/go-1.21/src/runtime/print.go", + "/usr/lib/go-1.21/src/runtime/proc.go", + "/usr/lib/go-1.21/src/runtime/profbuf.go", + "/usr/lib/go-1.21/src/runtime/retry.go", + "/usr/lib/go-1.21/src/runtime/rt0_darwin_arm64.s", + "/usr/lib/go-1.21/src/runtime/runtime.go", + "/usr/lib/go-1.21/src/runtime/runtime1.go", + "/usr/lib/go-1.21/src/runtime/runtime2.go", + "/usr/lib/go-1.21/src/runtime/rwmutex.go", + "/usr/lib/go-1.21/src/runtime/security_issetugid.go", + "/usr/lib/go-1.21/src/runtime/security_unix.go", + "/usr/lib/go-1.21/src/runtime/select.go", + "/usr/lib/go-1.21/src/runtime/sema.go", + "/usr/lib/go-1.21/src/runtime/signal_arm64.go", + "/usr/lib/go-1.21/src/runtime/signal_darwin_arm64.go", + "/usr/lib/go-1.21/src/runtime/signal_unix.go", + "/usr/lib/go-1.21/src/runtime/sigqueue.go", + "/usr/lib/go-1.21/src/runtime/slice.go", + "/usr/lib/go-1.21/src/runtime/stack.go", + "/usr/lib/go-1.21/src/runtime/stkframe.go", + "/usr/lib/go-1.21/src/runtime/string.go", + "/usr/lib/go-1.21/src/runtime/stubs.go", + "/usr/lib/go-1.21/src/runtime/symtab.go", + "/usr/lib/go-1.21/src/runtime/symtabinl.go", + "/usr/lib/go-1.21/src/runtime/sys_arm64.go", + "/usr/lib/go-1.21/src/runtime/sys_darwin.go", + "/usr/lib/go-1.21/src/runtime/sys_darwin_arm64.go", + "/usr/lib/go-1.21/src/runtime/sys_darwin_arm64.s", + "/usr/lib/go-1.21/src/runtime/sys_libc.go", + "/usr/lib/go-1.21/src/runtime/tagptr_64bit.go", + "/usr/lib/go-1.21/src/runtime/time.go", + "/usr/lib/go-1.21/src/runtime/time_nofake.go", + "/usr/lib/go-1.21/src/runtime/timestub.go", + "/usr/lib/go-1.21/src/runtime/tls_arm64.s", + "/usr/lib/go-1.21/src/runtime/trace.go", + "/usr/lib/go-1.21/src/runtime/traceback.go", + "/usr/lib/go-1.21/src/runtime/type.go", + "/usr/lib/go-1.21/src/runtime/typekind.go", + "/usr/lib/go-1.21/src/runtime/unsafe.go", + "/usr/lib/go-1.21/src/runtime/utf8.go", + "/usr/lib/go-1.21/src/runtime/write_err.go", + "/usr/lib/go-1.21/src/sort/sort.go", + "/usr/lib/go-1.21/src/sort/zsortinterface.go", + "/usr/lib/go-1.21/src/strconv/atoi.go", + "/usr/lib/go-1.21/src/strconv/decimal.go", + "/usr/lib/go-1.21/src/strconv/ftoa.go", + "/usr/lib/go-1.21/src/strconv/ftoaryu.go", + "/usr/lib/go-1.21/src/strconv/itoa.go", + "/usr/lib/go-1.21/src/strconv/quote.go", + "/usr/lib/go-1.21/src/strings/builder.go", + "/usr/lib/go-1.21/src/strings/strings.go", + "/usr/lib/go-1.21/src/sync/atomic/type.go", + "/usr/lib/go-1.21/src/sync/atomic/value.go", + "/usr/lib/go-1.21/src/sync/map.go", + "/usr/lib/go-1.21/src/sync/mutex.go", + "/usr/lib/go-1.21/src/sync/once.go", + "/usr/lib/go-1.21/src/sync/pool.go", + "/usr/lib/go-1.21/src/sync/poolqueue.go", + "/usr/lib/go-1.21/src/sync/runtime.go", + "/usr/lib/go-1.21/src/sync/rwmutex.go", + "/usr/lib/go-1.21/src/syscall/env_unix.go", + "/usr/lib/go-1.21/src/syscall/exec_unix.go", + "/usr/lib/go-1.21/src/syscall/rlimit.go", + "/usr/lib/go-1.21/src/syscall/rlimit_darwin.go", + "/usr/lib/go-1.21/src/syscall/route_bsd.go", + "/usr/lib/go-1.21/src/syscall/syscall.go", + "/usr/lib/go-1.21/src/syscall/syscall_bsd.go", + "/usr/lib/go-1.21/src/syscall/syscall_darwin.go", + "/usr/lib/go-1.21/src/syscall/syscall_unix.go", + "/usr/lib/go-1.21/src/syscall/zsyscall_darwin_arm64.go", + "/usr/lib/go-1.21/src/syscall/zsyscall_darwin_arm64.s", + "/usr/lib/go-1.21/src/time/format.go", + "/usr/lib/go-1.21/src/time/format_rfc3339.go", + "/usr/lib/go-1.21/src/time/sys_unix.go", + "/usr/lib/go-1.21/src/time/time.go", + "/usr/lib/go-1.21/src/time/zoneinfo.go", + "/usr/lib/go-1.21/src/time/zoneinfo_goroot.go", + "/usr/lib/go-1.21/src/time/zoneinfo_read.go", + "/usr/lib/go-1.21/src/time/zoneinfo_unix.go", + "/usr/lib/go-1.21/src/unicode/casetables.go", + "/usr/lib/go-1.21/src/unicode/tables.go", + "/usr/lib/go-1.21/src/unicode/utf8/utf8.go", + "" + ] + } + } \ No newline at end of file diff --git a/tests/data/gore_sym_app_win_exe_output.json b/tests/data/gore_sym_app_win_exe_output.json new file mode 100644 index 0000000..ad92e4d --- /dev/null +++ b/tests/data/gore_sym_app_win_exe_output.json @@ -0,0 +1,234 @@ +{ + "go_symbols": { + "build_info": { + "GoVersion": "go1.21.7", + "Path": "command-line-arguments", + "Main": { + "Path": "", + "Version": "", + "Sum": "", + "Replace": null + }, + "Deps": null, + "Settings": [ + { + "Key": "-buildmode", + "Value": "exe" + }, + { + "Key": "-compiler", + "Value": "gc" + }, + { + "Key": "CGO_ENABLED", + "Value": "0" + }, + { + "Key": "GOARCH", + "Value": "amd64" + }, + { + "Key": "GOOS", + "Value": "windows" + }, + { + "Key": "GOAMD64", + "Value": "v1" + } + ] + }, + "file_paths": [ + "/home/tg1999/Desktop/mini-app/main.go", + "/usr/lib/go-1.21/src/errors/errors.go", + "/usr/lib/go-1.21/src/errors/wrap.go", + "/usr/lib/go-1.21/src/fmt/format.go", + "/usr/lib/go-1.21/src/fmt/print.go", + "/usr/lib/go-1.21/src/internal/abi/abi.go", + "/usr/lib/go-1.21/src/internal/abi/type.go", + "/usr/lib/go-1.21/src/internal/abi/unsafestring_go120.go", + "/usr/lib/go-1.21/src/internal/bytealg/bytealg.go", + "/usr/lib/go-1.21/src/internal/bytealg/compare_amd64.s", + "/usr/lib/go-1.21/src/internal/bytealg/count_amd64.s", + "/usr/lib/go-1.21/src/internal/bytealg/count_native.go", + "/usr/lib/go-1.21/src/internal/bytealg/equal_amd64.s", + "/usr/lib/go-1.21/src/internal/bytealg/index_amd64.go", + "/usr/lib/go-1.21/src/internal/bytealg/index_amd64.s", + "/usr/lib/go-1.21/src/internal/bytealg/indexbyte_amd64.s", + "/usr/lib/go-1.21/src/internal/cpu/cpu.go", + "/usr/lib/go-1.21/src/internal/cpu/cpu_x86.go", + "/usr/lib/go-1.21/src/internal/cpu/cpu_x86.s", + "/usr/lib/go-1.21/src/internal/fmtsort/sort.go", + "/usr/lib/go-1.21/src/internal/itoa/itoa.go", + "/usr/lib/go-1.21/src/internal/poll/errno_windows.go", + "/usr/lib/go-1.21/src/internal/poll/fd.go", + "/usr/lib/go-1.21/src/internal/poll/fd_mutex.go", + "/usr/lib/go-1.21/src/internal/poll/fd_poll_runtime.go", + "/usr/lib/go-1.21/src/internal/poll/fd_windows.go", + "/usr/lib/go-1.21/src/internal/reflectlite/type.go", + "/usr/lib/go-1.21/src/internal/syscall/windows/net_windows.go", + "/usr/lib/go-1.21/src/internal/syscall/windows/registry/value.go", + "/usr/lib/go-1.21/src/internal/syscall/windows/registry/zsyscall_windows.go", + "/usr/lib/go-1.21/src/internal/syscall/windows/syscall_windows.go", + "/usr/lib/go-1.21/src/internal/syscall/windows/sysdll/sysdll.go", + "/usr/lib/go-1.21/src/internal/syscall/windows/zsyscall_windows.go", + "/usr/lib/go-1.21/src/io/fs/fs.go", + "/usr/lib/go-1.21/src/math/bits/bits.go", + "/usr/lib/go-1.21/src/math/exp_amd64.go", + "/usr/lib/go-1.21/src/math/unsafe.go", + "/usr/lib/go-1.21/src/os/dir.go", + "/usr/lib/go-1.21/src/os/error.go", + "/usr/lib/go-1.21/src/os/exec_windows.go", + "/usr/lib/go-1.21/src/os/executable.go", + "/usr/lib/go-1.21/src/os/executable_windows.go", + "/usr/lib/go-1.21/src/os/file.go", + "/usr/lib/go-1.21/src/os/file_posix.go", + "/usr/lib/go-1.21/src/os/file_windows.go", + "/usr/lib/go-1.21/src/os/path_windows.go", + "/usr/lib/go-1.21/src/os/proc.go", + "/usr/lib/go-1.21/src/path/filepath/match.go", + "/usr/lib/go-1.21/src/path/filepath/path.go", + "/usr/lib/go-1.21/src/path/filepath/path_windows.go", + "/usr/lib/go-1.21/src/reflect/abi.go", + "/usr/lib/go-1.21/src/reflect/asm_amd64.s", + "/usr/lib/go-1.21/src/reflect/float32reg_generic.go", + "/usr/lib/go-1.21/src/reflect/makefunc.go", + "/usr/lib/go-1.21/src/reflect/type.go", + "/usr/lib/go-1.21/src/reflect/value.go", + "/usr/lib/go-1.21/src/runtime/alg.go", + "/usr/lib/go-1.21/src/runtime/arena.go", + "/usr/lib/go-1.21/src/runtime/asm.s", + "/usr/lib/go-1.21/src/runtime/asm_amd64.s", + "/usr/lib/go-1.21/src/runtime/atomic_pointer.go", + "/usr/lib/go-1.21/src/runtime/cgocall.go", + "/usr/lib/go-1.21/src/runtime/chan.go", + "/usr/lib/go-1.21/src/runtime/cpuflags_amd64.go", + "/usr/lib/go-1.21/src/runtime/debug.go", + "/usr/lib/go-1.21/src/runtime/debugcall.go", + "/usr/lib/go-1.21/src/runtime/defs_windows_amd64.go", + "/usr/lib/go-1.21/src/runtime/duff_amd64.s", + "/usr/lib/go-1.21/src/runtime/env_posix.go", + "/usr/lib/go-1.21/src/runtime/error.go", + "/usr/lib/go-1.21/src/runtime/exithook.go", + "/usr/lib/go-1.21/src/runtime/extern.go", + "/usr/lib/go-1.21/src/runtime/fastlog2.go", + "/usr/lib/go-1.21/src/runtime/float.go", + "/usr/lib/go-1.21/src/runtime/hash64.go", + "/usr/lib/go-1.21/src/runtime/histogram.go", + "/usr/lib/go-1.21/src/runtime/iface.go", + "/usr/lib/go-1.21/src/runtime/internal/atomic/types.go", + "/usr/lib/go-1.21/src/runtime/internal/sys/intrinsics.go", + "/usr/lib/go-1.21/src/runtime/lfstack.go", + "/usr/lib/go-1.21/src/runtime/lock_sema.go", + "/usr/lib/go-1.21/src/runtime/lockrank.go", + "/usr/lib/go-1.21/src/runtime/lockrank_off.go", + "/usr/lib/go-1.21/src/runtime/malloc.go", + "/usr/lib/go-1.21/src/runtime/map.go", + "/usr/lib/go-1.21/src/runtime/map_fast32.go", + "/usr/lib/go-1.21/src/runtime/map_fast64.go", + "/usr/lib/go-1.21/src/runtime/map_faststr.go", + "/usr/lib/go-1.21/src/runtime/mbarrier.go", + "/usr/lib/go-1.21/src/runtime/mbitmap.go", + "/usr/lib/go-1.21/src/runtime/mcache.go", + "/usr/lib/go-1.21/src/runtime/mcentral.go", + "/usr/lib/go-1.21/src/runtime/mcheckmark.go", + "/usr/lib/go-1.21/src/runtime/mem.go", + "/usr/lib/go-1.21/src/runtime/mem_windows.go", + "/usr/lib/go-1.21/src/runtime/memclr_amd64.s", + "/usr/lib/go-1.21/src/runtime/memmove_amd64.s", + "/usr/lib/go-1.21/src/runtime/mfinal.go", + "/usr/lib/go-1.21/src/runtime/mfixalloc.go", + "/usr/lib/go-1.21/src/runtime/mgc.go", + "/usr/lib/go-1.21/src/runtime/mgclimit.go", + "/usr/lib/go-1.21/src/runtime/mgcmark.go", + "/usr/lib/go-1.21/src/runtime/mgcpacer.go", + "/usr/lib/go-1.21/src/runtime/mgcscavenge.go", + "/usr/lib/go-1.21/src/runtime/mgcstack.go", + "/usr/lib/go-1.21/src/runtime/mgcsweep.go", + "/usr/lib/go-1.21/src/runtime/mgcwork.go", + "/usr/lib/go-1.21/src/runtime/mheap.go", + "/usr/lib/go-1.21/src/runtime/mpagealloc.go", + "/usr/lib/go-1.21/src/runtime/mpagealloc_64bit.go", + "/usr/lib/go-1.21/src/runtime/mpagecache.go", + "/usr/lib/go-1.21/src/runtime/mpallocbits.go", + "/usr/lib/go-1.21/src/runtime/mprof.go", + "/usr/lib/go-1.21/src/runtime/mranges.go", + "/usr/lib/go-1.21/src/runtime/msize.go", + "/usr/lib/go-1.21/src/runtime/mspanset.go", + "/usr/lib/go-1.21/src/runtime/mstats.go", + "/usr/lib/go-1.21/src/runtime/mwbbuf.go", + "/usr/lib/go-1.21/src/runtime/netpoll.go", + "/usr/lib/go-1.21/src/runtime/netpoll_windows.go", + "/usr/lib/go-1.21/src/runtime/os_windows.go", + "/usr/lib/go-1.21/src/runtime/pagetrace_off.go", + "/usr/lib/go-1.21/src/runtime/panic.go", + "/usr/lib/go-1.21/src/runtime/pinner.go", + "/usr/lib/go-1.21/src/runtime/preempt.go", + "/usr/lib/go-1.21/src/runtime/preempt_amd64.s", + "/usr/lib/go-1.21/src/runtime/print.go", + "/usr/lib/go-1.21/src/runtime/proc.go", + "/usr/lib/go-1.21/src/runtime/rt0_windows_amd64.s", + "/usr/lib/go-1.21/src/runtime/runtime.go", + "/usr/lib/go-1.21/src/runtime/runtime1.go", + "/usr/lib/go-1.21/src/runtime/runtime2.go", + "/usr/lib/go-1.21/src/runtime/rwmutex.go", + "/usr/lib/go-1.21/src/runtime/select.go", + "/usr/lib/go-1.21/src/runtime/sema.go", + "/usr/lib/go-1.21/src/runtime/signal_windows.go", + "/usr/lib/go-1.21/src/runtime/sigqueue.go", + "/usr/lib/go-1.21/src/runtime/slice.go", + "/usr/lib/go-1.21/src/runtime/stack.go", + "/usr/lib/go-1.21/src/runtime/stkframe.go", + "/usr/lib/go-1.21/src/runtime/string.go", + "/usr/lib/go-1.21/src/runtime/stubs.go", + "/usr/lib/go-1.21/src/runtime/symtab.go", + "/usr/lib/go-1.21/src/runtime/symtabinl.go", + "/usr/lib/go-1.21/src/runtime/sys_windows_amd64.s", + "/usr/lib/go-1.21/src/runtime/sys_x86.go", + "/usr/lib/go-1.21/src/runtime/syscall_windows.go", + "/usr/lib/go-1.21/src/runtime/tagptr_64bit.go", + "/usr/lib/go-1.21/src/runtime/time.go", + "/usr/lib/go-1.21/src/runtime/time_nofake.go", + "/usr/lib/go-1.21/src/runtime/time_windows_amd64.s", + "/usr/lib/go-1.21/src/runtime/trace.go", + "/usr/lib/go-1.21/src/runtime/traceback.go", + "/usr/lib/go-1.21/src/runtime/type.go", + "/usr/lib/go-1.21/src/runtime/typekind.go", + "/usr/lib/go-1.21/src/runtime/unsafe.go", + "/usr/lib/go-1.21/src/runtime/utf8.go", + "/usr/lib/go-1.21/src/runtime/write_err.go", + "/usr/lib/go-1.21/src/runtime/zcallback_windows.s", + "/usr/lib/go-1.21/src/sort/sort.go", + "/usr/lib/go-1.21/src/sort/zsortinterface.go", + "/usr/lib/go-1.21/src/strconv/atoi.go", + "/usr/lib/go-1.21/src/strconv/decimal.go", + "/usr/lib/go-1.21/src/strconv/ftoa.go", + "/usr/lib/go-1.21/src/strconv/ftoaryu.go", + "/usr/lib/go-1.21/src/strconv/itoa.go", + "/usr/lib/go-1.21/src/strconv/quote.go", + "/usr/lib/go-1.21/src/strings/builder.go", + "/usr/lib/go-1.21/src/strings/strings.go", + "/usr/lib/go-1.21/src/sync/atomic/type.go", + "/usr/lib/go-1.21/src/sync/map.go", + "/usr/lib/go-1.21/src/sync/mutex.go", + "/usr/lib/go-1.21/src/sync/once.go", + "/usr/lib/go-1.21/src/sync/oncefunc.go", + "/usr/lib/go-1.21/src/sync/pool.go", + "/usr/lib/go-1.21/src/sync/poolqueue.go", + "/usr/lib/go-1.21/src/sync/runtime.go", + "/usr/lib/go-1.21/src/syscall/dll_windows.go", + "/usr/lib/go-1.21/src/syscall/exec_windows.go", + "/usr/lib/go-1.21/src/syscall/syscall.go", + "/usr/lib/go-1.21/src/syscall/syscall_windows.go", + "/usr/lib/go-1.21/src/syscall/wtf8_windows.go", + "/usr/lib/go-1.21/src/syscall/zsyscall_windows.go", + "/usr/lib/go-1.21/src/time/format.go", + "/usr/lib/go-1.21/src/time/time.go", + "/usr/lib/go-1.21/src/time/zoneinfo_abbrs_windows.go", + "/usr/lib/go-1.21/src/unicode/casetables.go", + "/usr/lib/go-1.21/src/unicode/tables.go", + "/usr/lib/go-1.21/src/unicode/utf16/utf16.go", + "/usr/lib/go-1.21/src/unicode/utf8/utf8.go", + "" + ] + } + } \ No newline at end of file diff --git a/tests/data/windows.exe b/tests/data/windows.exe new file mode 100644 index 0000000..4860ef2 Binary files /dev/null and b/tests/data/windows.exe differ diff --git a/tests/test_go_inspector.py b/tests/test_go_inspector.py new file mode 100644 index 0000000..26f9afe --- /dev/null +++ b/tests/test_go_inspector.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) nexB Inc. and others. All rights reserved. +# ScanCode is a trademark of nexB Inc. +# SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/scancode-plugins for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. +# + +import json +import os + +import pytest + +from src.go_inspector.plugin import collect_and_parse_symbols + +TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data") + + +def test_goresym_with_windows_exe(): + go_binary = os.path.join(TEST_DATA_DIR, "windows.exe") + with pytest.raises(Exception) as e: + collect_and_parse_symbols(go_binary) + + +def test_goresym_with_elf(): + go_binary = os.path.join(TEST_DATA_DIR, "arm_gentoo_elf") + with pytest.raises(Exception) as e: + collect_and_parse_symbols(go_binary) + + +@pytest.mark.parametrize( + "path", + [ + "app_lin_exe", + "app_mac_exe", + "app_win_exe", + ], +) +def test_goresym_with_mini_go_app_linux(path): + go_binary = os.path.join(TEST_DATA_DIR, path) + goresym_output = collect_and_parse_symbols(go_binary) + with open(os.path.join(TEST_DATA_DIR, f"gore_sym_{path}_output.json")) as f: + expected_output = json.load(f) + assert expected_output == goresym_output diff --git a/tests/test_skeleton_codestyle.py b/tests/test_skeleton_codestyle.py index 2eb6e55..a67814b 100644 --- a/tests/test_skeleton_codestyle.py +++ b/tests/test_skeleton_codestyle.py @@ -7,9 +7,9 @@ # See https://aboutcode.org for more information about nexB OSS projects. # +import configparser import subprocess import unittest -import configparser class BaseTests(unittest.TestCase): @@ -22,7 +22,7 @@ def test_skeleton_codestyle(self): if setup_cfg["metadata"]["name"] != "skeleton": return - args = "venv/bin/black --check -l 100 setup.py etc tests" + args = "venv/bin/black --check -l 100 setup.py tests " try: subprocess.check_output(args.split()) except subprocess.CalledProcessError as e: @@ -31,6 +31,6 @@ def test_skeleton_codestyle(self): print("===========================================================") raise Exception( "Black style check failed; please format the code using:\n" - " python -m black -l 100 setup.py etc tests", + " python -m black -l 100 setup.py tests", e.output, ) from e