From 4980293964534c28fbbbed4256a0d4c034c41ed9 Mon Sep 17 00:00:00 2001 From: idealley Date: Mon, 8 Jan 2018 16:11:01 +0100 Subject: [PATCH] first commmit --- .gitignore | 117 ++++++++++++++++++++++++++++++++++ .vscode/launch.json | 14 ++++ README.md | 41 ++++++++++++ compose.yml | 5 ++ load.sh | 28 ++++++++ rules/rules.gql | 17 +++++ schema/gdpr.gql | 151 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 373 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100755 README.md create mode 100755 compose.yml create mode 100755 load.sh create mode 100755 rules/rules.gql create mode 100755 schema/gdpr.gql diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ec6cd1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,117 @@ +# Specific project folders +db/ +dashboard/ +api/ + +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript + +# IDEs and editors (shamelessly copied from @angular/cli's .gitignore) +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Others +lib/ +data/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..78d820a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/api/src/index.js" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..57edb0a --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# GRAKN - GDPR + +This project describes how to use GRAKN to track personal data: +* imported and export +* use of each personal item (email, name) across systems +* authorization +* actions on that data +* User dashboard to have an overview on the use of his data. + +## Project structure +### /api +Node.js api that is used as the central point and lingua franca for all systems to communicate with GRAKN.AI. +The API uses a mongo database to manage API users, but that could be anything. +### /dashboard +Vuejs Dashboard that is used to display users data. That is the visible part of GDPR for users +### /data +Test data to load in GRAKN.AI +### /rules +Rules to lo load in GARKN.AI +### /schema + +# Todo +Add response from system after deletion + +# Schema +Grakn GDPR schema example. +TODO add content schema. + + +# Getting started +Call the loading script with the following params: +```js + './load.sh ' +``` + +The path is the path to the `grakn` install directory if GRAKN is installed at the root: +```js + './load.sh grakn grakn' +``` + +This script will load the ontology, the demo data and the rules. diff --git a/compose.yml b/compose.yml new file mode 100755 index 0000000..b3195ee --- /dev/null +++ b/compose.yml @@ -0,0 +1,5 @@ +grakn: + container_name: GRAKN + image: graknlabs/grakn + restart: always + volumes: ~/db:/grakn/db/ \ No newline at end of file diff --git a/load.sh b/load.sh new file mode 100755 index 0000000..3963fd7 --- /dev/null +++ b/load.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +## Usage: ./load.sh PATH_TO_GRAKN KEYSPACE + +# The following will make the script future proof +GRAKN="$HOME/$1" +LOAD="$GRAKN/./graql console -f" +BATCH="$GRAKN/./graql console -b" + +KEYSPACE="-k $2" + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +RULES="$DIR/rules" +DATA="$DIR/data" + +# Change this with the directory of the ontology you want to load +ONTOLOGY="$DIR/schema" + + +echo "Loading ontology and rules" +date; $LOAD "$ONTOLOGY/gdpr.gql" $KEYSPACE +date; $LOAD "$RULES/rules.gql" $KEYSPACE + +echo "Loading some fake data" +date; $LOAD "$DATA/test.gql" $KEYSPACE + +date \ No newline at end of file diff --git a/rules/rules.gql b/rules/rules.gql new file mode 100755 index 0000000..c14e51d --- /dev/null +++ b/rules/rules.gql @@ -0,0 +1,17 @@ +define + +is-authorized sub rule, +when { + (demand: $a, needed: $b) isa needs; + (requisite: $b, requester: $c ) isa requires; +} then { + (authorizer: $a, authorized: $c) isa authorizes; +}; + +is-revoked sub rule, +when { + (revoker:$a, revoked:$b) isa revoke; + (requisite:$b, requester: $c) isa requires; +} then { + (withdrawer:$a, withdrawn:$c) isa withdraws; +}; diff --git a/schema/gdpr.gql b/schema/gdpr.gql new file mode 100755 index 0000000..029f02b --- /dev/null +++ b/schema/gdpr.gql @@ -0,0 +1,151 @@ +define + +# Entities +anonymous sub entity + has timestamp + + plays incognito; + +person sub entity + has timestamp + has type + has identifier + + plays identified + plays imported + plays importer + plays exported + plays exporter + plays owner; + +property sub entity is-abstract + has value + plays owned + plays demand + plays authorizer + plays exported + plays imported + plays revoker + plays withdrawer; + +last-name sub property; +first-name sub property; +email sub property; + +address sub property + has value; +city sub address; +zip sub address; +street1 sub address; +street2 sub address; +street3 sub address; + +system sub entity + has value + has icon + + plays importer + plays exporter + plays requester + plays authorized + plays exported-to + plays imported-to; + +authorization sub entity + has name + has description + has timestamp + has expiration-date + + plays needed + plays requisite + plays revoked + plays withdrawn; + +# Resources +value sub attribute datatype string; +icon sub attribute datatype string; +name sub attribute datatype string; +description sub attribute datatype string; +timestamp sub attribute datatype long; +expiration-date sub attribute datatype date; +type sub attribute datatype string; +identifier sub attribute datatype long; + +# Relations + +## Attributes belong to a person +belongs sub relationship + relates owner + relates owned; + +## match an anonymous person with a real one +identifies sub relationship + has timestamp + + relates incognito + relates identified; + +## A system requires a property through an authorization +## This is usefull as a system can be quired and display +## all the properties it needs to work. +requires sub relationship + relates requester + relates requisite; + +## Attributes (email, first-name, etc.) demand an +## authorizaiton to be used by systems +needs sub relationship + relates demand + relates needed; + +## relation beteween an attribute and a system + +action sub relationship is-abstract + has timestamp; + +import sub action + relates imported + relates importer + relates imported-to; + +export sub action + relates exported + relates exporter + relates exported-to; + +revoke sub action + relates revoked + relates revoker; + +## relations used by inferences +authorizes sub relationship + relates authorized + relates authorizer; + +withdraws sub relationship + relates withdrawn + relates withdrawer; + +# Roles +owner sub role; +owned sub role; +requester sub role; +requisite sub role; +demand sub role; +needed sub role; +incognito sub role; +identified sub role; +authorized sub role; +authorizer sub role; +imported sub role; +importer sub role; +imported-to sub role; +exported sub role; +exporter sub role; +exported-to sub role; +revoked sub role; +revoker sub role; +withdrawn sub role; +withdrawer sub role; +