Skip to content

Commit

Permalink
Public release
Browse files Browse the repository at this point in the history
  • Loading branch information
jdz committed Dec 30, 2019
0 parents commit 10efdc5
Show file tree
Hide file tree
Showing 56 changed files with 10,427 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/pastelyzer*
21 changes: 21 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[submodule "deps/Postmodern"]
path = deps/postmodern
url = https://github.com/jdz/Postmodern.git
[submodule "deps/cl-ppcre"]
path = deps/cl-ppcre
url = https://github.com/jdz/cl-ppcre.git
[submodule "deps/cl-base64"]
path = deps/cl-base64
url = https://github.com/jdz/cl-base64.git
[submodule "deps/cl-log"]
path = deps/cl-log
url = https://github.com/jdz/cl-log.git
[submodule "deps/cl-speedy-queue"]
path = deps/cl-speedy-queue
url = https://github.com/jdz/cl-speedy-queue.git
[submodule "deps/ip"]
path = deps/ip
url = https://github.com/jdz/ip.git
[submodule "deps/2am"]
path = deps/2am
url = https://gitlab.common-lisp.net/dkochmanski/2am.git
17 changes: 17 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Copyright (c) 2018-2019 CERT.LV

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
119 changes: 119 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#+TITLE: Pastelyzer

* Introduction

This is ~pastelyzer~: the paste analyzer. There is a
[[file:doc/usage.org][user manual]] in ~doc~ directory.

The easiest way to run ~pastelyzer~ is by using the provided binary.

* Runtime dependencies
** Libraries

The following libraries must be installed on the target system:

- ~libssl~
- ~libzmq~ (version 3+)

*** Ubuntu Bionic (18.04), Eoan (19.10) packages

- ~libssl1.1~
- ~libzmq5~

** Database

To run ~pastelyzer~ in standalone mode a PostgreSQL database (at least version
*9.5*) is required. Use the SQL script in
[[file:../support/schema.sql][support/schema.sql]] to initialize the database:

#+BEGIN_EXAMPLE
$ psql -d pastelyzer < support/schema.sql
#+END_EXAMPLE

* Compilation
** Set up a working Common Lisp environment

~pastelyzer~ works with SBCL and ClozureCL:

- http://sbcl.org/
- https://ccl.clozure.com/

We strongly suggest using SBCL (which is also the implementation used in the
examples below). Most Linux distributions already have an ~sbcl~ package
available.

** Install system packages

To follow the instructions below you'll need the following software:

- C compiler (~gcc~).
- ~curl~ (to download Quicklisp).
- ~git~ (to clone ~pastelyzer~).
- Header files for ~libssl~ and ~libzmq~.

If you're using Ubuntu, you can install all of the above using the following
command:

#+BEGIN_EXAMPLE
# apt install build-essential curl git libssl-dev libzmq3-dev sbcl
#+END_EXAMPLE

** Install Quicklisp

An abridged version of the official
[[https://www.quicklisp.org/beta/#installation][Quicklisp install
instructions]]:

#+BEGIN_EXAMPLE
$ curl -O https://beta.quicklisp.org/quicklisp.lisp
$ sha256sum quicklisp.lisp
4a7a5c2aebe0716417047854267397e24a44d0cce096127411e9ce9ccfeb2c17 quicklisp.lisp
$ sbcl --load quicklisp.lisp \
--eval '(quicklisp-quickstart:install)' \
--quit
#+END_EXAMPLE

** Clone the source repository

#+BEGIN_EXAMPLE
$ git clone --recurse-submodules https://github.com/cert-lv/pastelyzer.git
$ cd pastelyzer
#+END_EXAMPLE

** Install dependencies

This has to be done only once (whenever the lisp library dependencies
change). In the ~pastelyzer~ directory run the ~bin/build.sh~ script with
~load-deps~ command:

#+BEGIN_EXAMPLE
$ bin/build.sh load-deps
#+END_EXAMPLE

** Run the test suite (optional)

#+BEGIN_EXAMPLE
$ bin/build.sh test
#+END_EXAMPLE

** Build an executable

Run ~bin/build.sh~ script with no parameters in ~pastelyzer~ directory:

#+BEGIN_EXAMPLE
$ bin/build.sh
#+END_EXAMPLE

* Copyright and License

~pastelyzer~ is released under the terms of zlib/libpng license. See
[[file:LICENSE]] file.

* Acknowledgements

This work was partially funded by CEF (Connecting Europe Facility) funding
under "Improving Cyber Security Capacities in Latvia"
(INEA/CEF/ICT/A2017/1528784).

#+ATTR_HTML: :height 100px :align center
[[file:doc/img/en_square_cef_logo.png]]
159 changes: 159 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#!/bin/sh
#
# This script may look ugly, but that's because it is POSIX Shell
# Command Language compliant:
#
# http://pubs.opengroup.org/onlinepubs/9699919799/
#
# The main issue is the lack of arrays, so the only way to build a
# command-line without issues with whitespace is to use the `set'
# built-in.

set -e

SCRIPT="$0"
SCRIPT_NAME=$(basename "$0")
BINDIR=$(dirname "$0")
ROOT=$(readlink -en "${BINDIR}/../")
BUILD_ID="nil"

usage() {
echo "Usage: $SCRIPT_NAME {operation|implementation}*"
echo
echo " operation: build|test (default: build)"
echo " implementation: sbcl|ccl (default: sbcl)"
}

calculate_build_id() {
local rel_tag
local n_master
local n_branch
local hash
local release
local build_id
local git="git -C ${ROOT}"

rel_tag=$($git describe --tags --match="rel-*" --abbrev=0 master 2> /dev/null)\
|| {
echo "No release tag found, cannot calculate build id." >&2
return
}

n_master=$($git rev-list master --not "${rel_tag}" --count)
n_branch=$($git rev-list HEAD --not master --count)
release="${rel_tag#rel-}"
build_id="${release}"

if [ ! "$n_master" -eq 0 ]; then
build_id="${release}.${n_master}"
fi

hash=$($git rev-parse --short HEAD)

if [ $n_branch -eq 0 ]; then
build_id="${build_id}-${hash}"
else
branch=$($git rev-parse --abbrev-ref HEAD)
build_id="${build_id}.${branch}.${n_branch}-${hash}"
fi

BUILD_ID="\"${build_id}\""
}

OPERATION="build"
LISP="sbcl"

while [ 0 -lt $# ] ; do
case "$1" in
sbcl)
LISP=sbcl
;;
ccl)
LISP=ccl
;;
test)
OPERATION=test
;;
load-deps)
OPERATION=load-deps
;;
--help|-h)
usage
exit 0
;;
*)
echo "$SCRIPT: Unrecognized option '$1'."
echo "Try '$SCRIPT --help' for more information."
exit 1
;;
esac
shift
done

# Implementation-specific options.
case $LISP in
sbcl)
set -- \
--dynamic-space-size 2048 \
--no-sysinit \
--no-userinit \
--eval "(sb-ext:disable-debugger)" \
--eval "(sb-ext:restrict-compiler-policy 'safety 1)" \
--eval "(sb-ext:restrict-compiler-policy 'debug 1)"
;;
ccl)
set -- --batch --no-init
;;
esac

# Common options.
set -- "$@" \
--eval "(push :hunchentoot-no-ssl *features*)" \
--eval "(require :asdf)"

# Build options.
case "$OPERATION" in
test)
case $LISP in
sbcl)
set -- "$@" \
--eval "(proclaim '(optimize (debug 3) (safety 3)))" \
--eval "(asdf:test-system \"pastelyzer\")" \
--eval "(sb-ext:exit :code (if 2am::*fail-count* 1 0))"
;;
ccl)
set -- "$@" \
--eval "(proclaim '(optimize (debug 3) (safety 3)))" \
--eval "(asdf:test-system \"pastelyzer\")" \
--eval "(ccl:quit (if 2am::*fail-count* 1 0))"
;;
esac
;;
load-deps)
set -- "$@" \
--load ~/quicklisp/setup.lisp \
--eval "(ql:quickload :swank)" \
--eval "(push '#:swank-indentation swank-loader::*contribs*)" \
--eval "(swank-loader:init :load-contribs t :setup nil :reload t)" \
--eval "(ql:quickload \"pastelyzer\")" \
--quit
;;
*)
calculate_build_id
set -- "$@" \
--eval "(asdf:load-system :swank)" \
--eval "(push '#:swank-indentation swank-loader::*contribs*)" \
--eval "(swank-loader:init :load-contribs t :setup nil :reload t)" \
--eval "(asdf:load-system \"pastelyzer\")" \
--eval "(setq pastelyzer::*build-id* ${BUILD_ID})" \
--eval "(proclaim '(optimize (speed 2) (safety 1)))" \
--eval "(asdf:make \"pastelyzer\")"
if [ -f "${BINDIR}/pastelyzer" ]; then
mv -f "${BINDIR}/pastelyzer" "${BINDIR}/pastelyzer.old"
fi
;;
esac

export CL_SOURCE_REGISTRY="${ROOT}/:${ROOT}/deps//:~/quicklisp/dists/quicklisp/software//"

"$LISP" "$@"
1 change: 1 addition & 0 deletions deps/2am
Submodule 2am added at 1d2fd2
1 change: 1 addition & 0 deletions deps/cl-base64
Submodule cl-base64 added at b71933
1 change: 1 addition & 0 deletions deps/cl-log
Submodule cl-log added at 50cd29
1 change: 1 addition & 0 deletions deps/cl-ppcre
Submodule cl-ppcre added at c0730c
1 change: 1 addition & 0 deletions deps/cl-speedy-queue
Submodule cl-speedy-queue added at 9ae2a5
1 change: 1 addition & 0 deletions deps/ip
Submodule ip added at 29e53c
1 change: 1 addition & 0 deletions deps/postmodern
Submodule postmodern added at 119d73
Binary file added doc/img/cli-33E400e1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/en_square_cef_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 10efdc5

Please sign in to comment.