generated from ngi-nix/project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Noise Explorer command-line tool (#1)
* modified * added README * format check implemented and remarks in review addressed * q * default.nix and shell.nix restored as per the template
- Loading branch information
1 parent
5388489
commit 3b372b8
Showing
8 changed files
with
1,640 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[Noise Explorer Repository](https://source.symbolic.software/noiseexplorer/noiseexplorer) | ||
|
||
|
||
<!-- GETTING STARTED --> | ||
## Getting Started | ||
|
||
The Noise Explorer command-line tool can parse Noise Handshake Patterns according to the original specification. It can generate cryptographic models for formal verification, including security queries, top-level processes and malicious principals, for testing against an active or passive attacker. Noise Explorer can also generate fully functional discrete implementations for any Noise Handshake Pattern, written in the Go and Rust programming languages, as well as WebAssembly binaries. | ||
Noise Explorer can also render results from the ProVerif output into an elegant and easy to read HTML format: the pattern results that can be explored on Noise Explorer were generated using the Noise Explorer command-line tool. | ||
|
||
### Prerequisites | ||
Install Nix with flake support as given in [https://nixos.wiki/wiki/Flakes](https://nixos.wiki/wiki/Flakes) | ||
In debian based systems the method is as follows after installing Nix | ||
```sh | ||
nix-env -iA nixpkgs.nixUnstable | ||
``` | ||
Edit either ~/.config/nix/nix.conf or /etc/nix/nix.conf and add: | ||
```sh | ||
experimental-features = nix-command flakes | ||
``` | ||
|
||
|
||
### Installation | ||
|
||
1. The flake can be installed like other Nix flakes. | ||
|
||
2. The command line tool operates on noise pattern files from the repository and creates output in files. | ||
|
||
3. Therefore the required noise patttern files can be copied from result/src/ folder and use it from working directory. | ||
|
||
4. The process can be as follows | ||
```sh | ||
nix develop | ||
node noiseExplorer.js | ||
``` | ||
5. The output will be as follows | ||
```sh | ||
Noise Explorer version 0.3 (specification revision 34) | ||
Noise Explorer has three individual modes: generation, rendering and web interface. | ||
|
||
Generation: | ||
--generate=(json|pv|go|rs|wasm): Specify output format. | ||
--pattern=[file]: Specify input pattern file (required). | ||
--attacker=(active|passive): Specify ProVerif attacker type (default: active). | ||
|
||
Rendering: | ||
--render: Render results from ProVerif output files into HTML. | ||
--pattern=[file]: Specify input pattern file (required). | ||
--activeModel=[file]: Specify ProVerif active attacker model (required). | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,77 @@ | ||
{ | ||
description = "(insert short project description here)"; | ||
description = "Commandline tool for testing Noise Protocol for parse Noise Handshake Patterns"; | ||
|
||
# Nixpkgs / NixOS version to use. | ||
inputs.nixpkgs.url = "nixpkgs/nixos-20.09"; | ||
inputs = { | ||
nixpkgs.url = "nixpkgs/nixos-unstable"; | ||
}; | ||
|
||
# Upstream source tree(s). | ||
inputs.hello-src = { url = git+https://git.savannah.gnu.org/git/hello.git; flake = false; }; | ||
inputs.gnulib-src = { url = git+https://git.savannah.gnu.org/git/gnulib.git; flake = false; }; | ||
|
||
outputs = { self, nixpkgs, hello-src, gnulib-src }: | ||
outputs = { self, nixpkgs }: | ||
let | ||
|
||
# Generate a user-friendly version numer. | ||
version = builtins.substring 0 8 hello-src.lastModifiedDate; | ||
|
||
# System types to support. | ||
supportedSystems = [ "x86_64-linux" ]; | ||
|
||
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. | ||
supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; | ||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); | ||
|
||
# Nixpkgs instantiated for supported system types. | ||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlay ]; }); | ||
|
||
in | ||
|
||
{ | ||
defaultPackage = forAllSystems (system: (import nixpkgs { | ||
inherit system; | ||
overlays = [ self.overlay ]; | ||
}).noiseExplorer); | ||
|
||
# A Nixpkgs overlay. | ||
overlay = final: prev: { | ||
|
||
hello = with final; stdenv.mkDerivation rec { | ||
name = "hello-${version}"; | ||
|
||
src = hello-src; | ||
|
||
buildInputs = [ autoconf automake gettext gnulib perl gperf texinfo help2man ]; | ||
|
||
preConfigure = '' | ||
mkdir -p .git # force BUILD_FROM_GIT | ||
./bootstrap --gnulib-srcdir=${gnulib-src} --no-git --skip-po | ||
''; | ||
|
||
meta = { | ||
homepage = "https://www.gnu.org/software/hello/"; | ||
description = "A program to show a familiar, friendly greeting"; | ||
}; | ||
}; | ||
|
||
}; | ||
|
||
# Provide some binary packages for selected system types. | ||
packages = forAllSystems (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ self.overlay ]; | ||
}; | ||
in | ||
{ | ||
inherit (nixpkgsFor.${system}) hello; | ||
inherit (pkgs) noiseExplorer; | ||
}); | ||
|
||
# The default package for 'nix build'. This makes sense if the | ||
# flake provides only one package or there is a clear "main" | ||
# package. | ||
defaultPackage = forAllSystems (system: self.packages.${system}.hello); | ||
|
||
# A NixOS module, if applicable (e.g. if the package provides a system service). | ||
nixosModules.hello = | ||
{ pkgs, ... }: | ||
{ | ||
nixpkgs.overlays = [ self.overlay ]; | ||
|
||
environment.systemPackages = [ pkgs.hello ]; | ||
|
||
#systemd.services = { ... }; | ||
}; | ||
overlay = final: prev: { | ||
noiseExplorer = final.callPackage ./noiseExplorer { }; | ||
}; | ||
|
||
# Tests run by 'nix flake check' and by Hydra. | ||
checks = forAllSystems (system: { | ||
inherit (self.packages.${system}) hello; | ||
devShell = forAllSystems (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ self.overlay ]; | ||
}; | ||
|
||
# Additional tests, if applicable. | ||
test = | ||
with nixpkgsFor.${system}; | ||
stdenv.mkDerivation { | ||
name = "hello-test-${version}"; | ||
nodeDependencies = (pkgs.callPackage ./noiseExplorer/dep.nix { }).shell.nodeDependencies; | ||
in | ||
pkgs.mkShell { | ||
|
||
buildInputs = [ hello ]; | ||
|
||
unpackPhase = "true"; | ||
buildInputs = with pkgs; [ | ||
cargo | ||
nodejs | ||
go | ||
rustc | ||
wasm | ||
wasm-pack | ||
]; | ||
|
||
buildPhase = '' | ||
echo 'running some integration tests' | ||
[[ $(hello) = 'Hello, world!' ]] | ||
''; | ||
|
||
installPhase = "mkdir -p $out"; | ||
}; | ||
}); | ||
|
||
# A VM test of the NixOS module. | ||
vmTest = | ||
with import (nixpkgs + "/nixos/lib/testing-python.nix") { | ||
checks = forAllSystems (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ self.overlay ]; | ||
}; | ||
|
||
makeTest { | ||
nodes = { | ||
client = { ... }: { | ||
imports = [ self.nixosModules.hello ]; | ||
}; | ||
}; | ||
|
||
testScript = | ||
'' | ||
start_all() | ||
client.wait_for_unit("multi-user.target") | ||
client.succeed("hello") | ||
''; | ||
}; | ||
}); | ||
|
||
in | ||
{ | ||
format = pkgs.runCommand "check-format" | ||
{ | ||
buildInputs = with pkgs; [ cargo nodejs go rustc wasm wasm-pack ]; | ||
} | ||
'' | ||
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.} | ||
touch $out | ||
#nixpkgs-fmt check sucessfull | ||
''; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ stdenv, lib, fetchgit, fetchurl, nodejs, pkgs }: | ||
let | ||
nodeDependencies = (pkgs.callPackage ./dep.nix { }).shell.nodeDependencies; | ||
in | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "NoiseExplorer"; | ||
|
||
version = "1.0.3"; | ||
|
||
src = fetchgit { | ||
url = "https://source.symbolic.software/noiseexplorer/noiseexplorer.git"; | ||
rev = "5b03267416fd5deb8b08f9d254b4c64b00baa676"; | ||
sha256 = "sha256-hXTKrRDpdmHvGgIyPnyjYopNgvewvxbzEgBxOfFa62w="; | ||
}; | ||
|
||
buildInputs = with pkgs; [ cargo nodejs go rustc wasm wasm-pack ]; | ||
|
||
buildPhase = '' | ||
ln -s ${nodeDependencies}/lib/node_modules ./node_modules | ||
export PATH="${nodeDependencies}/bin:$PATH" | ||
cd src | ||
pegjs -o parser/noiseParser.js parser/noiseParser.pegjs | ||
echo -n "[NoiseExplorer] Generating NoiseParser..." | ||
echo "Parser Generated" | ||
cd util | ||
bash genModels.sh | ||
bash genHtml.sh | ||
''; | ||
|
||
|
||
installPhase = '' | ||
mkdir -p $out/bin | ||
cd ../../ | ||
cp -vr . $out | ||
cp ${pkgs.writeScript "noiseexplorer" ''${nodejs}/bin/node ${src}/src/noiseExplorer.js $0 $1 $2''} $out/bin/noiseexplorer | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# This file has been generated by node2nix 1.9.0. Do not edit! | ||
|
||
{ pkgs ? import <nixpkgs> { | ||
inherit system; | ||
} | ||
, system ? builtins.currentSystem | ||
, nodejs ? pkgs."nodejs-12_x" | ||
}: | ||
|
||
let | ||
nodeEnv = import ./node-env.nix { | ||
inherit (pkgs) stdenv lib python2 runCommand writeTextFile; | ||
inherit pkgs nodejs; | ||
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null; | ||
}; | ||
in | ||
import ./node-packages.nix { | ||
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit; | ||
inherit nodeEnv; | ||
} |
Oops, something went wrong.