Giter VIP home page Giter VIP logo

Comments (6)

pluhin avatar pluhin commented on August 24, 2024

Do we have any updates related to this issue?

I also have same during execution of ./scan.sh or grabhtml.sh

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /tmp/tmp.SviSLngD8f/-: no such file or directory

from microscanner-wrapper.

pluhin avatar pluhin commented on August 24, 2024

I checked, i think it relevant to this section

RUN if [ ! -d /etc/ssl/certs/ ] || { [ ! -f /etc/ssl/certs/ca-certificates.crt ] && [ ! -f /etc/ssl/certs/ca-bundle.crt ]; }; then \
  PACKAGE_MANAGER=$(basename \
    $({ command -v apk apt yum false 2>/dev/null || which apk apt yum false; } \
    | head -n1)); \
  if [ "${PACKAGE_MANAGER}" = "apk" ]; then \
    apk --update add ca-certificates; \
  elif [ "${PACKAGE_MANAGER}" = "apt" ]; then \
    apt update \
      && apt install --no-install-recommends -y ca-certificates \
      && update-ca-certificates; \
  elif [ "${PACKAGE_MANAGER}" = "yum" ]; then \
    yum install -y ca-certificates; \
  else \
    echo 'ca-certificates not found and package manager not apk, apt, or yum. Aborting' >&2; \
    exit 1; \
  fi; \
fi;
EOL

    cat <<EOL
ADD ${MICROSCANNER_SOURCE} /tmp/microscanner
USER root
RUN [ -x /tmp/microscanner ] || chmod +x /tmp/microscanner \
  && sync \
  && /tmp/microscanner --version \
  && /tmp/microscanner ${MICROSCANNER_OPTIONS} ${MICROSCANNER_TOKEN}
EOL ```

this specification of Dockerfile

from microscanner-wrapper.

lukebond avatar lukebond commented on August 24, 2024

sorry for not replying to you earlier. what is the base OS of the images you're scanning @tuhaolam @pluhin? can you give me a public docker image with which i can reproduce the issue? it's working fine for me on my laptop (Arch Linux), using a few common images such as ubuntu, alpine and centos

from microscanner-wrapper.

kevinchowvungle avatar kevinchowvungle commented on August 24, 2024

@lukebond I could reproduce this with:

MICROSCANNER_TOKEN=**** ./scan.sh debian:8
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /tmp/tmp.vfm37E4NtR/-: no such file or directory

Thanks!

from microscanner-wrapper.

aqeelbutt avatar aqeelbutt commented on August 24, 2024

Any update on this!? I am stuck on this same error.

from microscanner-wrapper.

JackShort avatar JackShort commented on August 24, 2024

I was able to solve this problem by forking my own version of the repository and changing a line in the scan.sh to the following:

#!/bin/bash
set -euo pipefail

MICROSCANNER_TOKEN="${MICROSCANNER_TOKEN:-}"
MICROSCANNER_OPTIONS="${MICROSCANNER_OPTIONS:-}"
DOCKER_IMAGE="${1:-}"
TEMP_IMAGE_TAG=$(LC_CTYPE=C tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w 32 | head -n 1 | tr '[:upper:]' '[:lower:]' || true)

main() {
  local MICROSCANNER_BINARY MICROSCANNER_SOURCE
  [[ -z ${MICROSCANNER_TOKEN} ]] && {
    print_usage
    exit 1
  }
  [[ -z ${DOCKER_IMAGE} ]] && {
    print_usage
    exit 1
  }

  trap cleanup EXIT

  TEMP_DIR=$(mktemp -d)
  cp -r ./* "${TEMP_DIR}"/
  cd "${TEMP_DIR}"

  MICROSCANNER_SOURCE="https://get.aquasec.com/microscanner"
  if [[ "${USE_LOCAL:-0}" == 1 ]] \
    && MICROSCANNER_BINARY=$(
      {
        unset -f microscanner
        unalias microscanner
      } &>/dev/null
      command -v microscanner 2>/dev/null
    ); then

    printf "Using local "
    microscanner --version

    cp "${MICROSCANNER_BINARY}" ./microscanner
    MICROSCANNER_SOURCE="microscanner"
    echo
  fi

  {
    cat <<EOL
FROM ${DOCKER_IMAGE}
USER root
EOL

    cat <<'EOL'
RUN if [ ! -d /etc/ssl/certs/ ] || { [ ! -f /etc/ssl/certs/ca-certificates.crt ] && [ ! -f /etc/ssl/certs/ca-bundle.crt ]; }; then \
  PACKAGE_MANAGER=$(basename \
    $({ command -v apk apt yum false 2>/dev/null || which apk apt yum false; } \
    | head -n1)); \
  if [ "${PACKAGE_MANAGER}" = "apk" ]; then \
    apk --update add ca-certificates; \
  elif [ "${PACKAGE_MANAGER}" = "apt" ]; then \
    apt update \
      && apt install --no-install-recommends -y ca-certificates \
      && update-ca-certificates; \
  elif [ "${PACKAGE_MANAGER}" = "yum" ]; then \
    yum install -y ca-certificates; \
  else \
    echo 'ca-certificates not found and package manager not apk, apt, or yum. Aborting' >&2; \
    exit 1; \
  fi; \
fi;
EOL

    cat <<EOL
ADD ${MICROSCANNER_SOURCE} /tmp/microscanner
RUN [ -x /tmp/microscanner ] || chmod +x /tmp/microscanner \
  && sync \
  && /tmp/microscanner --version \
  && /tmp/microscanner ${MICROSCANNER_OPTIONS} ${MICROSCANNER_TOKEN}
EOL

  } | docker build --force-rm -t "${TEMP_IMAGE_TAG}" -f ./Dockerfile .
}

print_usage() {
  echo "Usage: MICROSCANNER_TOKEN=xxxxxxxxxxxxxxxx ./scan.sh DOCKER_IMAGE"
}

cleanup() {
  if docker inspect --type=image "${TEMP_IMAGE_TAG}" &>/dev/null; then
    docker image rm --force "${TEMP_IMAGE_TAG}" || true
  fi
  rm -rf "${TEMP_DIR}" || true
}

main

These changes copied everything from the current directory (where the dockerfile currently exists) to the temporary directory that the script creates to build the docker image. I changed the docker build line in the scan.sh file to point to the correct file in the directory. This should solve your problem.

from microscanner-wrapper.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.