]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Create setup script, add examples directory (includes tal dir).
authorpcarana <pc.moreno2099@gmail.com>
Fri, 18 Oct 2019 19:39:34 +0000 (14:39 -0500)
committerpcarana <pc.moreno2099@gmail.com>
Thu, 31 Oct 2019 19:18:51 +0000 (13:18 -0600)
-The script invites to agree ARIN RPA and downloads ARIN's TAL. Additionally, downloads the rest of the TALS, creates a local repository directory, and an example configuration file.
-Create 'examples' directory to include examples of: configuration file, SLURM, TALs.
-Move 'tal' directory to 'examples/tal'.
-Update docs, add the usage of the setup script at Installation module.

docs/installation.md
examples/README.md [new file with mode: 0644]
examples/config.json [new file with mode: 0644]
examples/demo.slurm [new file with mode: 0644]
examples/tal/README.md [new file with mode: 0644]
examples/tal/afrinic.tal [moved from tal/afrinic.tal with 100% similarity]
examples/tal/apnic.tal [moved from tal/apnic.tal with 100% similarity]
examples/tal/lacnic.tal [moved from tal/lacnic.tal with 100% similarity]
examples/tal/ripe.tal [moved from tal/ripe.tal with 100% similarity]
fort_setup.sh [new file with mode: 0755]
tal/README.md [deleted file]

index 8661bc00831db3ece2f8310cf1d5b9fd447f8314..8aa64a335854b0f3f95a18149a8900e6ca4b0d45 100644 (file)
@@ -7,8 +7,9 @@ title: Compilation and Installation
 ## Index
 
 1. [Dependencies](#dependencies)
-2. [Option 1: Installing the Debian package](#option-1-installing-the-debian-package)
-3. [Option 2: Compiling and installing the release tarball](#option-2-compiling-and-installing-the-release-tarball)
+2. [Setup script](#setup-script)
+3. [Option 1: Installing the Debian package](#option-1-installing-the-debian-package)
+4. [Option 2: Compiling and installing the release tarball](#option-2-compiling-and-installing-the-release-tarball)
        1. [Debian version](#debian-version)
        2. [OpenBSD version](#openbsd-version)
        3. [CentOS version](#centos-version)
@@ -16,7 +17,7 @@ title: Compilation and Installation
        5. [openSUSE Leap version](#opensuse-leap-version)
        6. [FreeBSD version](#freebsd-version)
        7. [Slackware version](#slackware-version)
-4. [Option 3: Compiling and installing the git repository](#option-3-compiling-and-installing-the-git-repository)
+5. [Option 3: Compiling and installing the git repository](#option-3-compiling-and-installing-the-git-repository)
 
 ## Dependencies
 
@@ -30,6 +31,31 @@ The dependencies are
 
 Fort is currently supported in *64-bit* OS. A 32-bit OS may face the [Year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) when handling dates at certificates, and currently there's no work around for this.
 
+## Setup script
+
+> ![img/warn.svg](img/warn.svg) This script exists merely to ease the ARIN TAL download (and some other additional stuff), it isn't a prerequisite to compile or run FORT validator, although we strongly advise to fetch ARIN TAL (using this script or by other means) in order to get the whole RPKI validated by FORT validator.
+
+The script can be found [here](https://github.com/NICMx/FORT-validator/blob/v{{ site.fort-latest-version }}/fort_setup.sh). It only expects one argument: an _existent directory path_ where the 5 RIRs TALS will be downloaded.
+
+Basically, it does the following:
+1. Display message to agree ARIN RPA.
+2. If agreed, download ARIN TAL to the received arg (named `TALS_PATH` from now on).
+3. Download the rest of the TALs to `TALS_PATH`.
+4. Try to create directory `/var/cache/fort/repository`, on error create `/tmp/fort/repository`.
+5. Create configuration file with [`tal`](https://nicmx.github.io/FORT-validator/usage.html#--tal) and [`local-repository`](https://nicmx.github.io/FORT-validator/usage.html#--local-repository) members, with a value of `TALS_PATH` (absolute path) and the directory path created at the previous step.
+6. Display FORT validator execution examples:
+  - Using the created configuration file (uses the arg [`-f`](https://nicmx.github.io/FORT-validator/usage.html#--configuration-file)).
+  - Using the values of the configuration file (uses the args [`--tal`](https://nicmx.github.io/FORT-validator/usage.html#--tal) and [`--local-repository`](https://nicmx.github.io/FORT-validator/usage.html#--local-repository)).
+
+Preferably, run this script with the same user what will run FORT validator. It's recommended that the user has write permission in `/var/cache`, since the script will try to create a directory there ([see more](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s05.html)). Here's an execution example:
+
+{% highlight bash %}
+# Get the script
+wget https://raw.githubusercontent.com/NICMx/FORT-validator/v{{ site.fort-latest-version }}/fort_setup.sh
+mkdir ~/tal
+./fort_setup.sh ~/tal
+{% endhighlight %}
+
 ## Option 1: Installing the Debian package
 
 {% highlight bash %}
diff --git a/examples/README.md b/examples/README.md
new file mode 100644 (file)
index 0000000..279c61f
--- /dev/null
@@ -0,0 +1,6 @@
+# Examples
+
+This folder contains the following examples:
+- `config.json`: configuration file mostly with the default values used by the validator. Can be set as value of [`--configuration-file`](https://nicmx.github.io/FORT-validator/usage.html#--configuration-file).
+- `demo.slurm`: valid SLURM file mostly with the same values as in [RFC 8416 section 3.5](https://tools.ietf.org/html/rfc8416#section-3.5). Can be set as value of [`--slurm`](https://nicmx.github.io/FORT-validator/usage.html#--slurm).
+- `tal/`: directory that contains almost all RIRs TALs, [read more](https://github.com/NICMx/FORT-validator/blob/master/examples/tal/README.md).
diff --git a/examples/config.json b/examples/config.json
new file mode 100644 (file)
index 0000000..0c5d114
--- /dev/null
@@ -0,0 +1,54 @@
+{
+  "tal": "/tmp/fort/tal/",
+  "local-repository": "/tmp/fort/repository/",
+  "sync-strategy": "root",
+  "shuffle-uris": false,
+  "maximum-certificate-depth": 32,
+  "mode": "server",
+  "server": {
+    "address": "127.0.0.1",
+    "port": "8323",
+    "backlog": 64,
+    "interval": {
+      "validation": 3600,
+      "refresh": 3600,
+      "retry": 600,
+      "expire": 7200
+    }
+  },
+  "slurm": "/tmp/fort/",
+  "log": {
+    "level": "warning",
+    "output": "console",
+    "color-output": false,
+    "file-name-format": "global-url"
+  },
+  "rsync": {
+    "program": "rsync",
+    "arguments-recursive": [
+      "--recursive",
+      "--delete",
+      "--times",
+      "--contimeout=20",
+      "$REMOTE",
+      "$LOCAL"
+    ],
+    "arguments-flat": [
+      "--times",
+      "--contimeout=20",
+      "--dirs",
+      "$REMOTE",
+      "$LOCAL"
+    ]
+  },
+  "incidences": [
+    {
+      "name": "incid-hashalg-has-params",
+      "action": "ignore"
+    }
+  ],
+  "output": {
+    "roa": "/tmp/fort/roas.csv",
+    "bgpsec": "/tmp/fort/bgpsec.csv"
+  }
+}
diff --git a/examples/demo.slurm b/examples/demo.slurm
new file mode 100644 (file)
index 0000000..0d662e5
--- /dev/null
@@ -0,0 +1,42 @@
+{
+  "slurmVersion": 1,
+  "validationOutputFilters": {
+    "prefixFilters": [
+      {
+        "prefix": "192.0.2.0/24",
+        "comment": "All VRPs encompassed by prefix"
+      },
+      {
+        "asn": 64496,
+        "comment": "All VRPs matching ASN"
+      },
+      {
+        "prefix": "198.51.100.0/24",
+        "asn": 64497,
+        "comment": "All VRPs encompassed by prefix, matching ASN"
+      }
+    ],
+    "bgpsecFilters": [
+      {
+        "asn": 64496,
+        "comment": "All keys for ASN"
+      }
+    ]
+  },
+  "locallyAddedAssertions": {
+    "prefixAssertions": [
+      {
+        "asn": 64496,
+        "prefix": "198.51.100.0/24",
+        "comment": "My other important route"
+      },
+      {
+        "asn": 64496,
+        "prefix": "2001:DB8::/32",
+        "maxPrefixLength": 48,
+        "comment": "My other important de-aggregated routes"
+      }
+    ],
+    "bgpsecAssertions": []
+  }
+}
diff --git a/examples/tal/README.md b/examples/tal/README.md
new file mode 100644 (file)
index 0000000..493ad56
--- /dev/null
@@ -0,0 +1,7 @@
+# TALs
+
+Most of the Trust Anchor Locators of the RIRs are included here for convenience. (But maybe you should get your own, for security.)
+
+The only one that's not included is ARIN's, because you need to agree to their [RPA](https://www.arin.net/resources/manage/rpki/tal/).
+
+In order to ease the ARIN TAL download, there's a script that does that for you: [fort_setup.sh](https://github.com/NICMx/FORT-validator/blob/master/fort_setup.sh). Read more about it at web docs section [Compilation and Installation](https://nicmx.github.io/FORT-validator/installation.html).
similarity index 100%
rename from tal/afrinic.tal
rename to examples/tal/afrinic.tal
similarity index 100%
rename from tal/apnic.tal
rename to examples/tal/apnic.tal
similarity index 100%
rename from tal/lacnic.tal
rename to examples/tal/lacnic.tal
similarity index 100%
rename from tal/ripe.tal
rename to examples/tal/ripe.tal
diff --git a/fort_setup.sh b/fort_setup.sh
new file mode 100755 (executable)
index 0000000..92fc1db
--- /dev/null
@@ -0,0 +1,173 @@
+#!/bin/sh
+
+# Setup script to ease FORT validator configuration (or even another RP),
+# expects one arg:
+#   $ ./fort_setup.sh TALS_PATH
+#
+# ADVISE: Preferably, run this script with the same user what will run FORT
+# validator. It's recommended that the user has write permission in /var/cache,
+# since the script will try to create a directory there (see
+# https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s05.html).
+# 
+# TALS_PATH must be an existent directory path, where the five RIRs TALs will
+# be downloaded.
+#
+# The main objective of this script is to simplify ARIN TAL download, by
+# explicitly agreeing its RPA. The rest of the actions are just facilitators to
+# run FORT validator.
+#
+# The script does the following:
+# 1. Display message to agree ARIN RPA.
+# 2. If agreed, download ARIN TAL to TALS_PATH arg.
+# 3. Download the rest of the TALs to TALS_PATH arg.
+# 4. Try to create directory '/var/cache/fort/repository', on error create
+#    '/tmp/fort/repository'.
+# 5. Create configuration file with 'tal' and 'local-repository' members,
+#    with a value of TALS_PATH (absolute path) and the directory path created
+#    at the previous step.
+# 6. Display FORT validator execution examples:
+#    - Using the created configuration file (uses the arg '-f').
+#    - Using the values of the configuration file (uses the args '--tal' and
+#      '--local-repository').
+
+exit_on_err()
+{
+  if ! [ $1 ] ; then
+    echo "$2"
+    exit 1
+  fi
+}
+
+# Request program (0=wget, 1=curl, 2=ftp)
+DOWN_OPT=0
+# Timeout for http requests
+DOWN_TIME=20
+
+get_tal()
+{
+  echo ""
+  echo "Fetching $1 TAL..."
+  case $DOWN_OPT in
+    0)
+      wget -O $2 -T $DOWN_TIME $3
+      RES=$?
+      break
+      ;;
+    1)
+      curl --output $2 --connect-timeout $DOWN_TIME -L $3
+      RES=$?
+      break
+      ;;
+    2)
+      # Just in case, specific for OpenBSD, older versions may not support -o or -w
+      ftp -o $2 -w $DOWN_TIME $3
+      RES=$?
+      break
+      ;;
+    *)
+      echo "Please check the script, there's a programming error."
+      exit 1
+      ;;
+  esac
+  exit_on_err "\"$RES\" = \"0\"" "Couldn't fetch $1 TAL, try again."
+}
+
+# Validate expected args
+exit_on_err "$# -gt 0" 'Usage: '"$0"' TALS_PATH.\nTALS_PATH must be an existent directory path.'
+exit_on_err "-d $1" "Path $1 isn't a directory."
+exit_on_err "-w $1" "Write permission denied on path $1."
+
+# Define download command
+if type wget >/dev/null 2>&1 ; then
+  DOWN_OPT=0
+elif type curl >/dev/null 2>&1 ; then
+  DOWN_OPT=1
+elif type ftp >/dev/null 2>&1 ; then
+  DOWN_OPT=2
+else
+  echo "Couldn't found 'wget', 'curl' nor 'ftp' programs; I need at least one of them to fetch the TALs."
+  exit 1
+fi
+
+# Declare variables
+TALS_LOC=$1
+GITHUB_TALS="https://raw.githubusercontent.com/NICMx/FORT-validator/master/examples/tal"
+ACCEPT="no"
+REPO_DIR="/var/cache/fort/repository"
+CONF_FILE="fort-config.json"
+ARIN_TAL="https://www.arin.net/resources/manage/rpki/arin-rfc7730.tal"
+
+# Agree ARIN RPA. Exit on denial or unknown response, download otherwise.
+echo ""
+echo "Please download and read ARIN Relying Party Agreement (RPA) from https://www.arin.net/resources/manage/rpki/rpa.pdf"
+echo ""
+echo -n "Once you've read and if you agree ARIN RPA, type \"yes\" to proceed with ARIN's TAL download: "
+read ACCEPT
+exit_on_err "\"$ACCEPT\" = \"yes\"" '\nYou haven'"'"'t agreed ARIN RPA! You can manually download its TAL or try running this script again.\n\nWe strongly advise to download ARIN TAL so that the Relying Party (validator) can validate the whole RPKI.'
+
+get_tal "ARIN" $TALS_LOC/arin-rfc7730.tal $ARIN_TAL
+
+# Get the rest of the TALs
+echo ""
+echo "Fetching the rest of the TALs"
+get_tal "LACNIC" "$TALS_LOC/lacnic.tal" "$GITHUB_TALS/lacnic.tal"
+get_tal "RIPE" "$TALS_LOC/ripe.tal" "$GITHUB_TALS/ripe.tal"
+get_tal "AFRINIC" "$TALS_LOC/afrinic.tal" "$GITHUB_TALS/afrinic.tal"
+get_tal "APNIC" "$TALS_LOC/apnic.tal" "$GITHUB_TALS/apnic.tal"
+
+# Try to create local repository directory
+mkdir -p -v $REPO_DIR
+if ! [ "$?" = "0" ] ; then
+  echo "Couldn't create dir $REPO_DIR."
+  REPO_DIR="/tmp/fort/repository"
+  echo ""
+  echo "Fallback, trying to create dir $REPO_DIR."
+  mkdir -p -v $REPO_DIR
+  if ! [ "$?" = "0" ] ; then
+    echo "Couldn't create dir $REPO_DIR."
+    REPO_DIR=""
+  fi
+fi
+
+# Get the absolute path, in case the configuration file is placed elsewhere
+TMP=$(readlink -f $TALS_LOC)
+if [ "$?" = "0" ] ; then
+  TALS_LOC=$TMP
+  TMP=""
+fi
+
+# Create or overwrite configuration file
+touch $CONF_FILE
+echo "{ " > $CONF_FILE
+if ! [ -z "$REPO_DIR" ] ; then
+  echo "  \"local-repository\": \"$REPO_DIR\"," >> $CONF_FILE
+fi
+echo "  \"tal\": \"$TALS_LOC\"" >> $CONF_FILE
+echo "} " >> $CONF_FILE
+
+# Display actions summary and usage examples
+echo ""
+echo "------------------------------------------------------"
+if [ -z "$TMP" ] ; then
+  echo "--------------------   Success!   --------------------"
+else
+  echo "-------------   Done (with warnings)!   --------------"
+fi
+echo "------------------------------------------------------"
+echo ""
+echo "- The five RIRs TAL's were downloaded to $TALS_LOC."
+if ! [ -z "$REPO_DIR" ] ; then
+  echo "- The directory $REPO_DIR was created, so it can be used as the local repository."
+fi
+if ! [ -z "$TMP" ] ; then
+  echo "- WARNING! Couldn't get absolute path of '$TALS_LOC', so I utilized this path '$TALS_LOC' at the configuration file"
+fi
+echo "- The configuration file '$CONF_FILE' was created with the following content:"
+cat $CONF_FILE
+echo ""
+echo "- This configuration file can be utilized with FORT validator, e.g.:"
+echo "  \$ fort --f \"$CONF_FILE\""
+echo "- Or its members can be utilized as FORT validator arguments, e.g.:"
+echo -n "  \$ fort --tal \"$TALS_LOC\"" && ! [ -z "$REPO_DIR" ] && echo " --local-repository \"$REPO_DIR\""
+echo "" 
+
diff --git a/tal/README.md b/tal/README.md
deleted file mode 100644 (file)
index 0a138a5..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-# TALs
-
-Most of the Trust Anchor Locators of the RIRs are included here for convenience. (But maybe you should get your own, for security.)
-
-The only one that's not included is ARIN's, because you need to agree to their [RPA](https://www.arin.net/resources/manage/rpki/tal/).