code-forensics icon indicating copy to clipboard operation
code-forensics copied to clipboard

Windows OS support documentation

Open smontanari opened this issue 7 years ago • 5 comments

It would be great if anyone using code-forensics in a Windows OS could take a little time to write a little page to explain the main gotchas required to get the tool running in Windows. If you can contribute let me know and I will be happy to include your documentation in the current wiki.

This does not mean I intend to fully support Windows in the future, my intent is just to provide some hints to people who are not keen to or cannot use linux, macos or docker.

smontanari avatar Jan 10 '18 23:01 smontanari

Silvio, I had created a Docker image to run code-forensics on Windows. The docker image supports Java and Node. The idea is to use git from inside that container to clone a repo but use host editors e.g. Sublime to edit the gulpfile and execute tasks.

Dockerfile

# Original from Michael Ruocco
FROM alpine:latest

ENV JAVA_VERSION_MAJOR=8 \
    JAVA_VERSION_MINOR=131 \
    JAVA_VERSION_BUILD=11 \
    JAVA_PACKAGE=jdk \
    JAVA_JCE=standard \
    JAVA_HOME=/opt/jdk \
    PATH=${PATH}:/opt/jdk/bin \
    GLIBC_VERSION=2.23-r3 \
    LANG=C.UTF-8

RUN set -ex && \
    apk upgrade --update && \
    apk add --update libstdc++ curl ca-certificates git subversion bash && \
    for pkg in glibc-${GLIBC_VERSION} glibc-bin-${GLIBC_VERSION} glibc-i18n-${GLIBC_VERSION}; do curl -sSL https://github.com/andyshinn/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/${pkg}.apk -o /tmp/${pkg}.apk; done && \
    apk add --allow-untrusted /tmp/*.apk && \
    rm -v /tmp/*.apk && \
    ( /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true ) && \
    echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
    /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
    mkdir /opt && \
    curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/java.tar.gz \
      http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/d54c1d3a095b4ff2b6607d096fa80163/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz && \
    gunzip /tmp/java.tar.gz && \
    tar -C /opt -xf /tmp/java.tar && \
    ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} /opt/jdk && \
    if [ "${JAVA_JCE}" == "unlimited" ]; then echo "Installing Unlimited JCE policy" >&2 && \
      curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" -o /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip \
        http://download.oracle.com/otn-pub/java/jce/${JAVA_VERSION_MAJOR}/jce_policy-${JAVA_VERSION_MAJOR}.zip && \
      cd /tmp && unzip /tmp/jce_policy-${JAVA_VERSION_MAJOR}.zip && \
      cp -v /tmp/UnlimitedJCEPolicyJDK8/*.jar /opt/jdk/jre/lib/security; \
    fi && \
    sed -i s/#networkaddress.cache.ttl=-1/networkaddress.cache.ttl=10/ $JAVA_HOME/jre/lib/security/java.security && \
    apk del curl glibc-i18n && \
    rm -rf /opt/jdk/*src.zip \
           /opt/jdk/lib/missioncontrol \
           /opt/jdk/lib/visualvm \
           /opt/jdk/lib/*javafx* \
           /opt/jdk/jre/plugin \
           /opt/jdk/jre/bin/javaws \
           /opt/jdk/jre/bin/jjs \
           /opt/jdk/jre/bin/orbd \
           /opt/jdk/jre/bin/pack200 \
           /opt/jdk/jre/bin/policytool \
           /opt/jdk/jre/bin/rmid \
           /opt/jdk/jre/bin/rmiregistry \
           /opt/jdk/jre/bin/servertool \
           /opt/jdk/jre/bin/tnameserv \
           /opt/jdk/jre/bin/unpack200 \
           /opt/jdk/jre/lib/javaws.jar \
           /opt/jdk/jre/lib/deploy* \
           /opt/jdk/jre/lib/desktop \
           /opt/jdk/jre/lib/*javafx* \
           /opt/jdk/jre/lib/*jfx* \
           /opt/jdk/jre/lib/amd64/libdecora_sse.so \
           /opt/jdk/jre/lib/amd64/libprism_*.so \
           /opt/jdk/jre/lib/amd64/libfxplugins.so \
           /opt/jdk/jre/lib/amd64/libglass.so \
           /opt/jdk/jre/lib/amd64/libgstreamer-lite.so \
           /opt/jdk/jre/lib/amd64/libjavafx*.so \
           /opt/jdk/jre/lib/amd64/libjfx*.so \
           /opt/jdk/jre/lib/ext/jfxrt.jar \
           /opt/jdk/jre/lib/ext/nashorn.jar \
           /opt/jdk/jre/lib/oblique-fonts \
           /opt/jdk/jre/lib/plugin.jar \
           /tmp/* /var/cache/apk/* && \
    echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf

ENV JAVA_HOME /opt/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin

RUN apk update
RUN apk add nodejs-npm
RUN npm install -g gulp
WORKDIR /root
RUN npm install code-forensics

ENTRYPOINT ["gulp"]
CMD ["list-analysis-tasks"]

cofo.bat I use the image with a small batch that wraps 2 docker run commands. Invoking the script with 'bash' as arguments brings me inside the image to clone a repository with subversion or git Alternatively, I invoke the script without argument to see the list of gulp tasks supported. It expects gulpfile.js to be available where it is invoked. This batch file expects a shared directory (here c:\Users\XYZ\code-forensic\shared) where code-forensics can access repos and persist outputs. Calling cofo bash allows you to run git clone from within the container. Calling it without arguments will force code-forensics to look for a gulpfile. Edit below.

@echo off
setlocal enabledelayedexpansion
if "%1" == "bash" (
  docker run -it --rm -v /c/Users/XYZ/code-forensic/shared:/root/shared --entrypoint bash code-forensic
) else (
  set "pwd=%cd::=%"
  docker run -it --rm -v /!pwd:\=/!:/root/shared -w /root/shared -p 3000:3000 code-forensic %*
  set pwd=
)

Issues The main issue so far is with UTF-8 encodings as shown in issue 17 which I had to enter manually. Setting Sublime format did not help.

jdevoo avatar Feb 14 '18 17:02 jdevoo

thank you @jdevoo. I'll put this info in the wiki and that will possibly contribute to share your approach with more users

smontanari avatar Feb 14 '18 21:02 smontanari

I've used this successfully in Windows 10 by using the Windows Subsystem for Linux (WSL) running Ubuntu. It's quite straightforward, install leiningen, install nodejs, install code-maat, install code-forensics and it works!

pierluca avatar Mar 05 '18 22:03 pierluca

Thank you @pierluca. Did you install leiningen to execute codemaat directly from the clojure source? code-forensics comes with a pre-packaged codemaat jar file (to ensure version compatibility) and should only require java to run codemaat commands.

smontanari avatar Mar 13 '18 01:03 smontanari

@smontanari Correct. One could probably skip that part then.

pierluca avatar Mar 14 '18 14:03 pierluca