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

General update #43

Merged
merged 6 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ deployed at [in-toto.engineering.nyu.edu](https://in-toto.engineering.nyu.edu/)
### Installation

**Requirements**
- [Python 2.7 (with development headers)](https://www.python.org) --
- [Python](https://www.python.org) --
backend
- [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
Expand All @@ -23,8 +23,7 @@ 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
sudo systemctl start mongod

# Install backend (c.f. requirements.txt)
pip install -r requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion create_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def create_material_rules(links, index):


def create_product_rules(links, index):
"""Create generic material rules (2 variants)
"""Create generic product rules (2 variants)

* ALLOW available products
* DISALLOW everything else
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Flask
Flask-PyMongo
Flask-WTF
-e git://github.com/in-toto/[email protected]#egg=in-totov0.2.3.dev5
Flask==1.1.2
Flask-PyMongo==2.3.0
Flask-WTF==0.14.3
in-toto==0.5.0
2 changes: 1 addition & 1 deletion templates/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>Create in-toto layout
<p>You will be asked to run a couple of in-toto commands while walking through this website, so make sure to have in-toto installed:</p>

<pre class="code">
pip install -e git+https://github.com/in-toto/[email protected]#egg=in-totov0.2.3.dev5
pip install in-toto
</pre>

<hr>
Expand Down
8 changes: 4 additions & 4 deletions wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import os
import uuid
import time
import StringIO
import io
import tarfile

from functools import wraps
Expand Down Expand Up @@ -362,7 +362,7 @@ def ajax_flash_messages(response):
show_messages(repsonse.messages).
"""

if (request.is_xhr and
if (request.headers.get("X-Requested-With") == "XMLHttpRequest" and
Copy link
Member

Choose a reason for hiding this comment

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

IIUC you are re-implementing the check that the deprecated request.is_xhr used to perform, right?

Did you have a chance to check if the jquery ajax call we use still sets that header, so that our ajax_flash_messages hook still works?

Copy link
Contributor Author

@SolidifiedRay SolidifiedRay Aug 9, 2020

Choose a reason for hiding this comment

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

Thanks a ton for the review @lukpueh !!

I checked the ajax_flash_messages hook and unfortunately something is not right.
For example, when I upload the functionary's public key in the functionaries page, the flash messages show up only after I manually refresh the page. When I try to remove the functionary that already has a pubkey, I also have to refresh the page to see the change and the flash message. I am not sure if there is something wrong with the ajax call or the ajax_flash_messages hook, but I will try to find up why this happened.

Copy link
Contributor Author

@SolidifiedRay SolidifiedRay Aug 11, 2020

Choose a reason for hiding this comment

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

As a follow-up, I will work on rule generation first, which seems to have a higher priority than this problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found ajax_flash_messages working again.

I check the jquery ajax call with the browser's network console, and it does include the X-Requested-With header with the value XMLHttpRequest. So I believe there is no problem with the code here. I doubt that it failed previously is because my Virtual Machine didn't run the WSGI server correctly.

Copy link
Member

Choose a reason for hiding this comment

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

I'll merge then. Thanks for the updates!

response.headers.get("Content-Type") == "application/json"):
response_data = json.loads(response.get_data())
response_data["messages"] = get_flashed_messages(with_categories=True)
Expand Down Expand Up @@ -1044,8 +1044,8 @@ def download_layout():
layout_metadata = in_toto.models.metadata.Metablock(signed=layout)

# Dump layout to memory file and server to user
layout_fp = StringIO.StringIO()
layout_fp.write("{}".format(layout_metadata))
layout_fp = io.BytesIO()
layout_fp.write("{}".format(layout_metadata).encode("utf-8"))
layout_fp.seek(0)
return send_file(layout_fp,
mimetype="application/json", as_attachment=True,
Expand Down