Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Initial PR (complete layout tool) #14

Merged
merged 189 commits into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from 181 commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
a6057fe
In-toto layout wizard clean slate + flask scaffold
lukpueh Apr 6, 2017
87377e5
Adds basic view and template for every wizard page
lukpueh Apr 6, 2017
5fc57ba
Adds basic "option group" to versioning template
lukpueh Apr 6, 2017
37b02e4
Adds SASS/SCSS support
lukpueh Apr 21, 2017
de866f8
Adds Boostrap frontend framework (v4 alpha)
lukpueh Apr 21, 2017
ec0298b
Adds dummy boostrap progress bar (WIP)
lukpueh Apr 21, 2017
d8ebd83
Rewrites basic option groups using Bootstrap/SCSS
lukpueh Apr 21, 2017
bcb456b
Override bootstrap's blue with wizard blue
lukpueh May 1, 2017
febd8b5
Adds dummy rows + recessed form in versioning page
lukpueh May 1, 2017
1d02fc6
Minor base.html changes
lukpueh May 3, 2017
65e2065
Finishes basic versioning page UI
lukpueh May 3, 2017
f3669c4
Adds vcs clone consent modal
lukpueh May 3, 2017
1aaecca
Moves out options grid to a partial
lukpueh May 3, 2017
d66839d
Changes code structure for option grid
lukpueh May 4, 2017
72b6235
Replace html grid/form partials with macros
lukpueh May 5, 2017
08a18c4
Minor base.html changes
lukpueh May 5, 2017
50937ca
Replaces Bootstrap collapse with Jquery slide
lukpueh May 5, 2017
7013cc9
Adds finished building page template
lukpueh May 5, 2017
29a141b
Removes `libsass` from requirements and wizard.py
lukpueh May 5, 2017
45e7820
Adds gulpfile.js for vendor js copying
lukpueh May 5, 2017
bb2ab0f
Adds basic drag-n-drop sorting to building page
lukpueh May 5, 2017
64a2c02
Minor replacement of lipsum text with lipsum func
lukpueh May 8, 2017
bd4c193
Adds finished quality management page template
lukpueh May 8, 2017
46bbcb0
Adds finished packaging page template
lukpueh May 8, 2017
e45f6da
Adds minor container/bg styling
lukpueh May 9, 2017
c9d3e71
Removes minified jquery.js from static
lukpueh May 9, 2017
25cae24
Adds minor container/bg styling II
lukpueh May 9, 2017
1c333a2
Adds D3.js, plus basic supply chain page template
lukpueh May 9, 2017
917e967
Adds svg element and styles for repsoniveness
lukpueh May 11, 2017
70f15f0
Adds not working D3 force-directed graph
lukpueh May 11, 2017
bef27ff
Adds dagre-d3 for DAG layouts plus basic example
lukpueh May 11, 2017
2bfc697
Adds server-side layout to graph data transform
lukpueh May 15, 2017
803ac9b
Updates JS/CSS to draw compound layout graph
lukpueh May 15, 2017
c0f4b48
Adds SVG graph scaling and centering
lukpueh May 15, 2017
d688b4d
Adds SVG viewBox JS init + basic styling
lukpueh May 15, 2017
03feedc
Moves graph drawing to client-side JS in ssc html
lukpueh May 19, 2017
266c289
Generalizes add/remove of html documents
lukpueh May 19, 2017
865a65c
Generalizes class names for html5 sorting
lukpueh May 19, 2017
ef615ed
Adds dynamic/sortable form to ssc page
lukpueh May 19, 2017
742c727
Adds dropzone.js for drag and drop file upload
lukpueh May 19, 2017
6e3166f
Adds basic authorization page with key dropzone
lukpueh May 19, 2017
b23fbfa
Adds "next" button to landing page
lukpueh May 19, 2017
a9a304e
Updates in-toto branch in requirements.txt
lukpueh May 22, 2017
c6ad00c
Adds select2 for pubkey multiselect on auth page
lukpueh May 22, 2017
48971b9
Updates dropzone preview style to match select2
lukpueh May 22, 2017
b7ed0d2
Adds basic Security Assessment page
lukpueh May 22, 2017
8dc69e6
Adds basic code snippet with custom select trick
lukpueh May 22, 2017
78d8b0a
Finishes basic wrap-up page
lukpueh May 23, 2017
45a0a52
Changes code textarea width to 100%
lukpueh May 23, 2017
d347318
Changes download btn on wrap-up page to full width
lukpueh May 23, 2017
d598ebe
Finishes basic guarantees page with "check" list
lukpueh May 23, 2017
be13453
Minor: Centers button on start page
lukpueh May 23, 2017
86873f5
Adds header text and adds content class
lukpueh May 23, 2017
88028c1
Removes h1 inheritance block form base
lukpueh May 24, 2017
c4242fd
Adds progress bar macro and custom progress values
lukpueh May 24, 2017
7f7a0d4
Removes compound nodes and changes arrow direction
lukpueh Jun 5, 2017
17685f2
Adds class to enable select items in input groups
lukpueh Jun 5, 2017
52be68d
Adds build step selection to QA page, plus styles
lukpueh Jun 5, 2017
3b5c1a0
Fixes z-index bug in option grid
lukpueh Jun 6, 2017
52f1f7d
Fixes 'in-toto' case in page and head title
lukpueh Jun 6, 2017
a68d0a1
Add basic tooldb, a dictionary of ssc tools
lukpueh Jun 12, 2017
2aa2c48
Make minor tweaks to tooldb
lukpueh Jun 12, 2017
4059e7d
Add vcs collection as template var to vcs view
lukpueh Jun 12, 2017
c62b9f4
Show VCS tools in versioning template
lukpueh Jun 12, 2017
215f79e
Minor change in option grid scss
lukpueh Jun 12, 2017
6696426
Minor change to start template (btn text)
lukpueh Jun 12, 2017
0e79420
Clean vcs tools in tooldb
lukpueh Jun 16, 2017
e3db4bf
Add user feedback facility to frontend
lukpueh Jun 16, 2017
e4e454c
Remove opt checkbox + case handling in form toggle
lukpueh Jun 16, 2017
ecda9b7
Change parameter passing in option_grid macro (WIP)
lukpueh Jun 16, 2017
d0137d1
Rename and update `option_custom` macro (WIP)
lukpueh Jun 16, 2017
325e530
Implement versioning backend
lukpueh Jun 16, 2017
b391579
Add comment textarea to form container macro
lukpueh Jun 16, 2017
a9ec1a2
Update versioning frontend with UI/macro changes
lukpueh Jun 16, 2017
792a87c
Add copy option form to form container click listener
lukpueh Jun 16, 2017
5fec449
Remove obsolete todo command from macros
lukpueh Jun 16, 2017
fa78346
Fix indentation in versioning template
lukpueh Jun 16, 2017
732f114
Shorten building tool name in tooldb
lukpueh Jun 16, 2017
a7cefb1
Implement building backend
lukpueh Jun 16, 2017
2a06c9d
Update versioning building with UI/macro changes
lukpueh Jun 16, 2017
6767bbc
Shorten qa tool name in tooldb (temp)
lukpueh Jun 19, 2017
a3b583a
Implement qa view + update qa template
lukpueh Jun 19, 2017
ed06bdf
Implement packaging view + update template
lukpueh Jun 20, 2017
bfa78a8
Update ssc graph generation + frontend changes
lukpueh Jun 22, 2017
d12b1e8
Add FIXME comment for qa step order to ssc view
lukpueh Jun 22, 2017
373173b
Add `inspection based on step` input
lukpueh Jun 22, 2017
de40e6a
Update misc in ssc template
lukpueh Jun 22, 2017
a669dc3
Update ssc template and implement backend
lukpueh Jun 23, 2017
fc25cdd
Add functionary page + frontend/backend
lukpueh Jun 30, 2017
6ef6791
Update authorizing template and implement backend
lukpueh Jun 30, 2017
1ec9a14
Update chaining template and implement backend
lukpueh Jun 30, 2017
e865c8f
Update wrap_up template and implement backend
lukpueh Jun 30, 2017
9025d91
Adds build layout based on uploaded links script
lukpueh Mar 23, 2017
c5d3a04
Libifies reverse layout
lukpueh Mar 24, 2017
819073e
Remove "<qa step> run before|after <build step>"
lukpueh Jun 30, 2017
5470ace
Fix in_toto.model import issue in backend
lukpueh Jun 30, 2017
c99b715
Store link filename instead of path to session
lukpueh Jun 30, 2017
96c42fb
Fix wrong order bug in chaining and wrap up
lukpueh Jun 30, 2017
8c2c709
Update cherry picked reverse_layout
lukpueh Jun 30, 2017
09ad936
Move demo usage code in reverse layout to main
lukpueh Jun 30, 2017
4699209
Add basic (generate and) download (reverse) layout
lukpueh Jun 30, 2017
86f04e2
Fix keyerror on empty session in wrap_up page
lukpueh Jul 6, 2017
05e5e81
Update download_layout to serve layout
lukpueh Jul 6, 2017
224571e
Add step authorization to layout creation
lukpueh Jul 6, 2017
9992e91
Fix wrong order bug on authorization page
lukpueh Jul 6, 2017
45fa2e3
Add basic inspection creation in download_layout
lukpueh Jul 6, 2017
f04df37
Add FIXME comment about file upload race condition
lukpueh Jul 6, 2017
6c1507c
Update keypair snippet to use in-toto-keygen
lukpueh Jul 6, 2017
11eebb6
Update inspection form and cmd assessment
lukpueh Jul 7, 2017
2f9eb47
Move "Add custom cmd" btn to top of option grid
lukpueh Jul 7, 2017
2b9b2bb
Change bg color for opt forms that are posted
lukpueh Jul 7, 2017
08bb201
Change opt-form to optionally add and sumit
lukpueh Jul 7, 2017
7cadd29
Remove opt-form template in form_container macro
lukpueh Jul 7, 2017
c3fdd36
Move form-container h2 to macro, toggle display
lukpueh Jul 7, 2017
95c68c6
Fix public key file load path bug
lukpueh Jul 12, 2017
f4c5329
Add `with_session_id` view decorator
lukpueh Jul 12, 2017
a5ca4c6
Introduce PyMongo for session data persistence
lukpueh Jul 12, 2017
381d8c9
Add mongo insert/update and query helper functions
lukpueh Jul 12, 2017
4fdabfd
Update views to store/get data in db
lukpueh Jul 12, 2017
efaf8df
Remove timestamp in some subdocuments
lukpueh Jul 13, 2017
c2a3769
Fix bug in persist subdocument with timestamp
lukpueh Jul 13, 2017
145c15d
Refactor software supply chain data structure
lukpueh Jul 13, 2017
b0b912f
Enable graph update on ssc form update
lukpueh Jul 14, 2017
3d4ef3f
Minor css class fixes in ssc template
lukpueh Jul 14, 2017
8a8f946
Add modifying/reporting step handling to ssc graph
lukpueh Jul 14, 2017
47e0563
Add step_modifies in backend
lukpueh Jul 14, 2017
8ce3a1e
Add include inspection checkboxes to QA page
lukpueh Jul 17, 2017
82dcf84
Big pubkey upload/persist refactoring
lukpueh Jul 18, 2017
d4ef8ef
Big link upload/persist refactoring
lukpueh Jul 19, 2017
b78d1b8
Change global JS function expressions to statements
lukpueh Jul 19, 2017
aa51870
Change functionary datastructure and DB operations
lukpueh Jul 20, 2017
f80c7a7
Change authorizing datastructure
lukpueh Jul 20, 2017
b5dd182
Change layout download to serve memory file
lukpueh Jul 20, 2017
c6714b4
Move "comment" form group to its own macro
lukpueh Jul 20, 2017
b24374c
Add comment form section to remaining pages
lukpueh Jul 20, 2017
ffbe92b
Remove some obsolete comments, fix typos
lukpueh Jul 20, 2017
dc41ea2
Remove unused layout_to_graph helper function
lukpueh Jul 20, 2017
5e0ac7f
Fix bug in dropzone link file remove callback
lukpueh Jul 20, 2017
1c91076
Enable link upload using tar(.gz) archive
lukpueh Jul 20, 2017
bcdabcb
Add simple refresh ssc on change option
lukpueh Jul 21, 2017
cb612f3
Add info log for new sessions
lukpueh Jul 21, 2017
84de860
Add ajax/json response hook to inject messages
lukpueh Jul 21, 2017
abde3bc
Minor: Remove debugging log statement
lukpueh Jul 21, 2017
1cc956d
Minor message container style changes
lukpueh Jul 21, 2017
cc919d1
Add CSRF tokens to forms and ajax requests
lukpueh Jul 24, 2017
4e66cc6
Change website title
lukpueh Jul 24, 2017
771bfac
Write text for landing page
lukpueh Jul 24, 2017
62df4eb
Update option grid logo and text style
lukpueh Jul 24, 2017
1f1baf8
Remove colored background from alert messages
lukpueh Jul 24, 2017
6f6a23d
Minor text + style changes in macros
lukpueh Jul 24, 2017
05a95df
Write text for versioning page
lukpueh Jul 24, 2017
762e16b
Write text for building page
lukpueh Jul 24, 2017
04b2147
Write text for QA page
lukpueh Jul 24, 2017
7a10de2
Write text for packaging page
lukpueh Jul 24, 2017
8f6c3c2
Write text for ssc page
lukpueh Jul 24, 2017
75c27f7
Write text for functionary page
lukpueh Jul 24, 2017
0927546
Write text for authorizing page
lukpueh Jul 24, 2017
3883da0
Write text for chaining page
lukpueh Jul 24, 2017
27d5321
Fix header level in ssc template
lukpueh Jul 25, 2017
9e050b4
Write text for wrap-up page
lukpueh Jul 25, 2017
05dd627
Remove obsolete files directory
lukpueh Jul 25, 2017
6a9ea9a
Fix typo and update README.md
lukpueh Jul 25, 2017
e3ed3c3
Add auto reload on template change setting
lukpueh Aug 16, 2017
d2867c4
Add beta tag and link to github io page to header
lukpueh Aug 16, 2017
5e24927
Update comments in reverse_layout module
lukpueh Aug 17, 2017
2f437a9
Add docstring and fix paths in sample wsgi file
lukpueh Aug 17, 2017
a265bb8
Update LICENSE title and copyright ownership
lukpueh Aug 17, 2017
a56bfdb
Add header docstring to gulpfile.js
lukpueh Aug 17, 2017
fa6a967
Add header docstring to main.js
lukpueh Aug 17, 2017
6a60ff9
Update comments and docstrings in main.js
lukpueh Aug 17, 2017
5ab4f28
Add header docstring to main.scss
lukpueh Aug 17, 2017
75f2b59
Update various fields in package.json and README
lukpueh Aug 18, 2017
88c0bd6
Add header docstring to tooldb.py
lukpueh Aug 18, 2017
a27f46f
Update docstrings/comments in wizard.py
lukpueh Aug 18, 2017
8ea6621
Add whitespace control template comments
lukpueh Aug 18, 2017
711faec
Add header docstring to templates/*.html
lukpueh Aug 18, 2017
4f7a895
Fix selected values not cloned bug
lukpueh Aug 29, 2017
f2104a3
Fix typo on building page
lukpueh Aug 29, 2017
1bbbc53
Fix wrong year in LICENSE file
lukpueh Aug 30, 2017
6f8e13d
Remove non-required fields from package.json
lukpueh Sep 14, 2017
ebf524d
Address various PR #14 comments
lukpueh Sep 14, 2017
7e82633
Replace md5/random value with uuid4 for session id
lukpueh Sep 14, 2017
415b866
Fix in-toto-sign snippet on wrap up page
lukpueh Sep 14, 2017
2091bd3
Update "you revisited a previous page" text
lukpueh Sep 14, 2017
1310274
Make data transformation function more defensive
lukpueh Sep 14, 2017
bc31725
Gitignore flask instance folder
lukpueh Sep 15, 2017
855e5cc
Update various sections in README
lukpueh Sep 15, 2017
9f311ff
Fix wrong use of "therefor" and "according"
lukpueh Sep 15, 2017
4d25719
Refactor "versioning" to "vcs"
lukpueh Sep 15, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Byte-compiled / optimized / DLL files

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a Flask app, what about ignoring Flask-specific files?

Example:

instance/
.webassets-cache

Copy link
Member Author

@lukpueh lukpueh Sep 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added instance/.
Adding .webassets-cache won't be necessary as we don't use webassets/Flask-Assets

__pycache__/
*.py[cod]
*$py.class

in-toto
node_modules

# Exclude vendor JS file, copy them freshly using:
# `gulp`
static/vendor/*
!static/vendor/.keep

files/*
!files/.keep

# Exclude *.css files, compile them freshly using:
# `sass static/scss/main.scss:static/css/main.scss.css`
.sass-cache
static/css/*
!static/css/.keep
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 New York University

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
This looks like a standard MIT license, and copyright is assigned to New York University as requested by @JustinCappos


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# in-toto Layout Creation Wizard

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider saying somewhere in the README that an instance of the layout tool is available and/or link to it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


A Flask based web app to guide project owners through creating an
[in-toto layout](https://in-toto.io).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked text is in-toto layout, so I was expecting a link to something about in-toto's layout tool.

Maybe linking to https://in-toto.engineering.nyu.edu/, where an instance of the layout tool exists, makes more sense? This repository is also more about the layout tool rather than in-toto.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


Mockups can be found at [`editor-and-wizard-wip/mockups`](https://github.com/in-toto/layout-web-tool/blob/editor-and-wizard-wip/mockups/layout-wizard.pdf).


### Installation

**Requirements**
- [Python 2.7](https://www.python.org/download/releases/2.7/) -- backend

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have to install any Python development headers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- [npm](https://www.npmjs.com/) -- frontend dependencies
- [Ruby](https://www.ruby-lang.org/en/documentation/installation/) and [SASS](http://sass-lang.com/install) -- CSS preprocessor
- [MongoDB](https://docs.mongodb.com/manual/installation/) -- to persist
user session data (for usage analysis)


```shell
# Start `mongod` (if not already running)
# Note: `service` won't be available in the future
sudo service mongod start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

service is an outdated debian/ubuntu construct. If you're using systemd compliant, this command should be

sudo systemctl start mongod

Can you check this out for me please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The official mongodb installation/usage guide suggests service mongod start for all supported Linux systems.

Copy link
Member

@SantiagoTorres SantiagoTorres Sep 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I guess they need to update their docs too. Could you at least leave a note for it? (serivce won't be available in the future)


# Install backend (c.f. requirements.txt)
pip install -r requirements.txt

# Install and vendorize frontend dependencies and compile scss
# c.f. dependencies and scripts in package.json
npm install
```

### Deployment
- Add an [instance folder](http://flask.pocoo.org/docs/0.12/config/#instance-folders) with your
deployment configuration, e.g.:
```python
# Example configuration in FLASK_APP_ROOT/instance/config.py
DEBUG = False
SECRET_KEY = '?\xbf,\xb4\x8d\xa3"<\x9c\xb0@\x0f5\xab,w\xee\x8d$0\x13\x8b83' #CHANGE THIS!!!!!

```

- Take a look at `wizard.wsgi` and [these`mod_wsgi` instructions](http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/)
for further guidance.

### Development Tips
- Run the development server like this:
```shell
python wizard.py
```
- Run a `sass` watcher during development to automatically compile css on file change:
```shell
sass --watch static/scss/main.scss:static/css/main.scss.css
```
- Make extensive use of (e.g. chrome's) browser developer tools, e.g. [map
DevTool files to your local workspace](https://developers.google.com/web/tools/setup/setup-workflow) to live edit `*.scss` and `*.js` files.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this project need an acknowledgement section?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Empty file added __init__.py
Empty file.
154 changes: 154 additions & 0 deletions create_layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python

"""
<Program Name>
create_layout.py
<Author>
Lukas Puehringer <lukas.puehringer@nyu.edu>
<Started>
March 23, 2017
<Copyright>
See LICENSE for licensing information.
<Purpose>
Creates a basic in-toto layout by reading an ordered list of step link files.
** Infer layout fields: **
expires:
default value
keys:
FIXME: Keys are currently ignored in this module
steps:
add steps in the order of passed link files
name:
link.name
expected_command:
link.command
threshold:
default value
material_matchrules/product_matchrules:
currently uses simple approach (see below)
FIXME: Should use more complex approach (see ideas below)
inspections:
FIXME Inspections are currently ignored in this module
signatures:
empty (use `in-toto-sign` command line utility)
** Infer step artifact rules (simple approach) **
** material_matchrules **
IF no materials were recorded
material_matchrules: [["DISALLOW", "*"]]
ELSE IF materials were recorded and it is the first step
material_matchrules: [["ALLOW", "*"]]
ELSE
material_matchrules: [["MATCH", "*", "WITH", "PRODUCTS", "FROM", <PREVIOUS STEP>]
** product_matchrules **
IF no products were recorded
product_matchrules: [["DISALLOW", "*"]]
ELSE products were recorded:
product_matchrules: [["ALLOW", "*"]]
** Ideas for more complexity: **
- explicitly, ALLOW or MATCH files by name instead of "*", e.g.:
material_matchrules = \
[["ALLOW", material] for material in links[index].materials.keys()]
- for MATCH rules
match only those that already were in the previous step
allow the rest by name
<Usage>
```
# Create a layout given an ordered list of link file paths
links = []
for LINK_PATH in LINK_PATHS:
link = in_toto.models.link.Link.read_from_file(LINK_PATH)
links.append(link)
layout = create_layout_from_ordered_links(links)
layout.dump()
```
"""
import os
import in_toto.models.link
import in_toto.models.layout

def create_material_matchrules(links, index):
"""Create generic material rules (3 variants)
* No materials recorded -> disallow any artifact
* Materials recorded (first step) -> allow artifacts that existed beforehand
* Materials recorded (latter step) -> match from previous products
Returns a list of material rules
NOTE: Read header docstring for ideas for more complexity. """

material_matchrules = []

if not links[index].materials:
material_matchrules = [["DISALLOW", "*"]]

elif index == 0 and links[index].materials:
material_matchrules = [["ALLOW", "*"]]

else:
material_matchrules = [
["MATCH", "*", "WITH", "PRODUCTS", "FROM", links[index - 1].name]]

return material_matchrules


def create_product_matchrules(links, index):
"""Create generic material rules (2 variants)
* No products recorded -> disallow any artifact
* Products recorded -> allow all artifacts
Returns a list of product rules
NOTE: Read header docstring for ideas for more complexity. """

if not links[index].products:
product_matchrules = [["DISALLOW", "*"]]

else:
product_matchrules = [["ALLOW", "*"]]

return product_matchrules


def create_layout_from_ordered_links(links):
"""Creates basic in-toto layout from an ordered list of in-toto link objects,
inferring material and product rules from the materials and products of the
passed links. """
# Create an empty layout
layout = in_toto.models.layout.Layout()
layout.keys = {}

for index, link in enumerate(links):
step_name = link.name
step = in_toto.models.layout.Step(name=step_name,
material_matchrules=create_material_matchrules(links, index),
product_matchrules=create_product_matchrules(links, index),
expected_command=link.command)

layout.steps.append(step)

return layout
51 changes: 51 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*****************************************************************
<File Name>
gulpfile.js

<Author>
Lukas Puehringer <lukas.puehringer@nyu.edu>

<Started>
May 05, 2017

<Copyright>
See LICENSE for licensing information.

<Purpose>
Front-end build tool used to copy third-party JS scripts to
static/vendor from where the app serves them.

TODO:
Add gulp task for scss (styles) compilation (on change)
Currently this is done with a separate command, i.e.
```
sass --watch static/scss/main.scss:static/css/main.scss.css
```
but it would be nice to have all in one place.

<Usage>
```
# Install front-end dependencies (in same directory)
npm install
# Run default gulp task
gulp
```

*****************************************************************/
var gulp = require("gulp");

gulp.task("default", function() {
var js = [
"node_modules/jquery/dist/jquery.js",
"node_modules/bootstrap/dist/js/bootstrap.js",
"node_modules/tether/dist/js/tether.js",
"node_modules/html5sortable/dist/html.sortable.js",
"node_modules/d3/d3.js",
"node_modules/dagre-d3/dist/dagre-d3.js",
"node_modules/dropzone/dist/dropzone.js",
"node_modules/select2/dist/js/select2.js"
];
js.forEach(function() {
gulp.src(js).pipe(gulp.dest("./static/vendor/"));
});
});
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "in-toto-layout-tool",
"version": "1.0.0-beta.0",
"scripts": {
"postinstall": "gulp && sass static/scss/main.scss:static/css/main.scss.css"
},
"dependencies": {
"bootstrap": "4.0.0-alpha.6",
"d3": "^3.5.17",
"dagre-d3": "^0.4.17",
"dropzone": "^4.3.0",
"gulp": "^3.9.1",
"html5sortable": "^0.5.1",
"select2": "^4.0.3"
}
}
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Flask
Flask-PyMongo
Flask-WTF
-e git://github.com/in-toto/in-toto.git@c39b04cec329bead34232a39742ebda5947633fd#egg=in-toto
Empty file added static/css/.keep
Empty file.
Loading