Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the goepel g-api #690

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .readthedocs.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions .readthedocs.yaml.license

This file was deleted.

6 changes: 6 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version = 1

[[annotations]]
path = ["**/.gitignore", "**/*.lock", ".python-version", "tests/bats/testfiles/*"]
SPDX-FileCopyrightText = "AISEC Pentesting Team"
SPDX-License-Identifier = "CC0-1.0"
1 change: 1 addition & 0 deletions contrib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/out
81 changes: 81 additions & 0 deletions contrib/download-g-api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: AISEC Pentesting Team
#
# SPDX-License-Identifier: Apache-2.0
#
set -eu

# There is no API. If the download does not work any more (or if there are updates)
# please check this page:
#
# https://www.goepel.com/automotive-test-solutions/support/software/g-api-software
#
ARCHIVE_NAME="g-api-Setup-2.2.10974_Release_Linux.run.zip"
RUN_SCRIPT_NAME="${ARCHIVE_NAME%.*}"
DOWNLOAD_URL="https://www.goepel.com/fileadmin/files/ats/software/g-api/$ARCHIVE_NAME"

is_running_under_podman() {
if [[ -n "${container:-}" && "$container" == "podman" ]]; then
return 0
fi
return 1
}

main() {
# If this script is not running under podman, then spawn podman and run
# itself within the container.

# Outside the container.
local extractdir
extractdir="/mnt$PWD/out"
if ! is_running_under_podman; then
podman run -it -v "$PWD:/mnt/$PWD" -w "/mnt/$PWD" --rm debian:trixie "$BASH_ARGV0" "$extractdir"

# Exit the parent script outside the container.
exit
fi

# Inside the container.
# Catch the directory from the commandline; supplied outside the container.
extractdir="$1"

apt-get install -U -y curl unzip make pciutils xdg-user-dirs

local tmpdir
tmpdir="$(mktemp -d)"

cd "$tmpdir"
curl -L -o "$ARCHIVE_NAME" "$DOWNLOAD_URL"

unzip "$ARCHIVE_NAME"

if [[ ! -r "$RUN_SCRIPT_NAME" ]]; then
echo "error: $ARCHIVE_NAME is not there!"
exit 1
fi

chmod +x "$RUN_SCRIPT_NAME"
mkdir -p "$extractdir"

echo "The goepel installer script is going to be executed now."
echo "This scipt will break your system and we do not recommend this to be run on a production system."
echo "For reference (especially point 1.4 and 1.5):"
echo ""
echo " https://wiki.debian.org/DontBreakDebian"
echo ""
echo "For this reason, the install script is run in a podman container."
echo "The installer will fail but it extracts the library and .so files."

"./$RUN_SCRIPT_NAME" --target "$extractdir" > "$extractdir/installer.log" 2>&1 || true

mkdir -p "$extractdir/lib"
cd "$extractdir/lib"
tar -xvf "../bin/g_api_lib.tar.gz"

echo "The extracted library will be available in: $extractdir"
echo "Headers are in: $extractdir/bin"
echo "Shared objects are in: $extractdir/lib"
}

main "$@"
26 changes: 26 additions & 0 deletions contrib/start-g-api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: AISEC Pentesting Team
#
# SPDX-License-Identifier: Apache-2.0

set -eu

if [[ "$#" != 1 ]]; then
echo "usage: $BASH_ARGV0 GAPID_PATH"
exit 1
fi

GAPID_PATH="$(realpath "$1")"

systemd-run \
--service-type=forking \
-p "PrivateTmp=true" \
-p "ProtectSystem=strict" \
-p "PrivateUsers=true" \
--unit "gapid.service" \
--user \
--collect \
unshare --map-root-user -- "$GAPID_PATH" -s 7

echo 'goepel gapid is running. Stop with "systemctl --user stop gapid.service"'.
4 changes: 2 additions & 2 deletions src/gallia/commands/script/flexray.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
assert sys.platform == "win32"

from gallia.command import AsyncScript, Script
from gallia.transports._ctypes_vector_xl_wrapper import FlexRayCtypesBackend
from gallia.transports.flexray_vector import FlexRayFrame, RawFlexRayTransport, parse_frame_type
from gallia.transports.vector._ctypes_vector_xl_wrapper import FlexRayCtypesBackend
from gallia.transports.vector.flexray import FlexRayFrame, RawFlexRayTransport, parse_frame_type


class FRDumpConfig(AsyncScriptConfig):
Expand Down
2 changes: 1 addition & 1 deletion src/gallia/transports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@


if sys.platform == "win32":
from gallia.transports.flexray_vector import FlexRayTPLegacyTransport, RawFlexRayTransport
from gallia.transports.vector.flexray import FlexRayTPLegacyTransport, RawFlexRayTransport

registry.append(RawFlexRayTransport)
registry.append(FlexRayTPLegacyTransport)
Expand Down
4 changes: 4 additions & 0 deletions src/gallia/transports/vector/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: AISEC Pentesting Team
#
# SPDX-License-Identifier: Apache-2.0

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from pydantic import BaseModel, ConfigDict, field_validator

from gallia.log import get_logger
from gallia.transports import BaseTransport, TargetURI, _ctypes_vector_xl, _ctypes_vector_xl_wrapper
from gallia.transports import BaseTransport, TargetURI
from gallia.transports.vector import _ctypes_vector_xl, _ctypes_vector_xl_wrapper
from gallia.utils import auto_int

assert sys.platform == "win32", "unsupported platform"
Expand Down
3 changes: 0 additions & 3 deletions tests/bats/testfiles/log-01.json.zst.license

This file was deleted.

3 changes: 0 additions & 3 deletions uv.lock.license

This file was deleted.

Loading