generated from ngi-nix/project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Noise Explorer command-line tool #1
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df2a511
modified
raghuramlavan 9e22293
added README
raghuramlavan e0fa16a
format check implemented and remarks in review addressed
raghuramlavan 4471516
q
raghuramlavan 57e3670
default.nix and shell.nix restored as per the template
raghuramlavan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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). | ||
|
This file was deleted.
Oops, something went wrong.
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 ]; | ||
raghuramlavan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
raghuramlavan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
''; | ||
raghuramlavan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you also need the source of the noise explorer as well ?
Perhaps you have it locally, but I don't think it's available to everybody.
Perhaps that explains why you needed to
cd src
further down.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fetched via
fetchgit
in default.nix which seems fine.But I agree, handling the source as a flake input will allow the user to change the source version via flakes interface (
nix flake lock --update-input
will be possible for example). That can be convenient, especially when this flake is used by other flakes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fetched in default.nix and try to use the same version in the flake.nix and also in default.nix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind putting the src in the inputs ?
It's a little clearer that way, it also provides a convenient update mechanism.