Skip to content

Commit 35c5fdf

Browse files
0xedwardfacebook-github-bot
authored andcommitted
Update Pysa quickstart
Reviewed By: gbleaney Differential Revision: D28416629 fbshipit-source-id: 8ebc243adc0a7e2bcd9823da34216724146c2de2
1 parent e632edd commit 35c5fdf

File tree

1 file changed

+45
-30
lines changed

1 file changed

+45
-30
lines changed

documentation/website/docs/pysa_quickstart.md

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ $ python3.8 -m venv ~/.venvs/pysa
6363
$ source ~/.venvs/pysa/bin/activate
6464
```
6565

66-
2. Install Pyre and SAPP in the virtual environment:
67-
```shell
68-
(pysa) $ pip install pyre-check fb-sapp
69-
```
70-
71-
3. Install dependencies for your project
66+
2. Install dependencies for your project
7267

7368
You can check which packages are installed in your virtual environment by looking at the files in:
7469
```shell
@@ -82,6 +77,11 @@ If you already have dependencies installed for your project in your virtual envi
8277

8378
Installing your project dependencies in your virtual environment will allow Pysa to provide you better results, because it allows Pysa to use [models](pysa_basics.md#model-files) that correspond to those dependencies and detect [sources](pysa_basics.md#sources) and [sinks](pysa_basics.md#sinks) that might be hidden in your dependencies' code
8479

80+
3. Install Pyre and SAPP in the virtual environment:
81+
```shell
82+
(pysa) $ pip install pyre-check fb-sapp
83+
```
84+
8585
4. Create Pyre configuration file in the project directory you want to run Pysa on:
8686

8787
`pyre init` will set up a [configuration file for Pyre (`.pyre_configuration`)](configuration.md) in your project's directory. The defaults for `pyre init` should cover most projects.
@@ -94,7 +94,7 @@ Installing your project dependencies in your virtual environment will allow Pysa
9494

9595
If your project isn't type annotated, running Pyre's type inference might improve your Pysa results. Note: this command will modify your code, but don't worry the type annotations won't affect your code at runtime.
9696
```shell
97-
(pysa) $ pyre -l . infer -r -i
97+
(pysa) $ pyre infer -r -i
9898
```
9999

100100
6. Set up SAPP with some high signal filters
@@ -137,12 +137,9 @@ We've provided you with some filters in SAPP to help you find a small subset of
137137
- [Introduction to Pysa](pysa_basics.md)
138138
- [DEF CON 28 Pysa Tutorial](https://www.youtube.com/watch?v=8I3zlvtpOww)
139139
- [Pysa Debugging Tips](pysa_false_negatives.md)
140-
- [SAPP Documentation](static_analysis_post_processor.md)
141-
<!-- TODO(edq) update SAPP docs -->
140+
- [SAPP Documentation](https://github.com/facebook/sapp#readme)
142141

143142
## Common Issues
144-
<!-- TODO(edq) If SAPP traces don't show the corresponding code for my project, that means the user you likely need to use --source-directory flag -->
145-
<!-- TODO(edq) Users will need to specific source directory if they have run pysa and sapp from outside their project folder -->
146143

147144
**Problem**: Running Pysa results in `ƛ Error: Could not find a pyre client.`
148145

@@ -211,6 +208,11 @@ $ python3.8 -m venv ~/.venvs/pysa
211208
$ (pysa) pip3 install wheel
212209
$ (pysa) python3.8 -m pip install --upgrade setuptools
213210
```
211+
----
212+
**Problem**: `pyre init` shows `ƛ Source directory path/to/dir does not exist. Be sure the source path is relative to the import_root`.
213+
214+
**Solution**: You will need to manually update `source_directories` in `.pyre_configuration`. Refer to [Pyre Global configuration section](configuration.md#the-global-configuration) to set up `source_directories`.
215+
214216
----
215217
**Problem**: Running `pyre analyze` results in a bunch of errors and Pysa stops running
216218

@@ -221,21 +223,17 @@ $ (pysa) python3.8 -m pip install --upgrade setuptools
221223

222224
**Solution**: Unfortunately, it is likely the case that your machine doesn't have enough memory to run Pysa on projects with similar size to yours.
223225

224-
---
225-
**Problem**: Running any `sapp` command results in `SyntaxError: future feature annotations is not defined`
226+
----
227+
**Problem**: `pyre analyze --no-verify` exits with error `ƛ Uncaught exception: (Invalid_argument "~/.venvs/pysa/lib/pyre_check/typeshed/stdlib/zlib.pyi is not a directory")`
226228

227-
**Solution**: SAPP requires Python 3.7. Ensure you are running a Python version later than Python 3.7
229+
**Solution**: Delete your virtual environment and recreate your virtual environment by following the steps in the [Initial configuration](#initial-configuration) section
228230
```shell
229-
$ python3 --version
231+
(pysa) $ deactivate
232+
$ rm -rf ~/.venvs/pysa
230233
```
231-
---
232-
**Problem**: I can't connect to the Web UI and it displays an error related to SSL. The SAPP server log displays a bunch of `400 Bad Request` error codes
233-
234-
**Solution**: Make sure you are visiting [`http://localhost:5000`](http://localhost:5000) and not `https://localhost:5000`
235-
236-
---
237-
**Problem**: I'm seeing a bunch of errors like `~/.venvs/pysa/lib/pyre_check/taint/filename.pysa: module.path.function_name is not part of the environment!`
234+
----
238235
<!-- TODO(T89279545) Update `not part of environment` sections after this task is done -->
236+
**Problem**: I'm seeing a bunch of errors like `~/.venvs/pysa/lib/pyre_check/taint/filename.pysa: module.path.function_name is not part of the environment!`
239237

240238
**Solution**:
241239
If you don't use the `module.path.function_name` mentioned in your project, you can ignore them. Pysa ships with many taint models for code that isn't present in all projects. The errors you are seeing is Pysa informing you that Pysa hasn't found the source code for that particular function in your project or your venv.
@@ -252,6 +250,28 @@ If you do use the `module.path.function_name` mentioned in your project and the
252250
"taint_models_path": "~/.venvs/pysa/lib",
253251
}
254252
```
253+
----
254+
**Problem**: Running any `sapp` command results in `SyntaxError: future feature annotations is not defined`
255+
256+
**Solution**: SAPP requires Python 3.7. Ensure you are running a Python version later than Python 3.7
257+
```shell
258+
$ python3 --version
259+
```
260+
----
261+
262+
<!-- TODO(T83001415) remove the section below after the todo is completed -->
263+
**Problem**: Running any `sapp` command results in a bunch of `SAWarning`s like
264+
```
265+
SAWarning: SAWarning: relationship 'Child.parent' will copy column parent.id to column child.parent_id, which conflicts with relationship(s): 'Parent.children' (copies parent.id to child.parent_id). If this is not the intention, consider if these relationships should be linked with back_populates, or if viewonly=True should be applied to one or more if they are read-only. For the less common case that foreign key constraints are partially overlapping, the orm.foreign() annotation can be used to isolate the columns that should be written towards. The 'overlaps' parameter may be used to remove this warning.
266+
```
267+
**Solution**: Please ignore the `SAWarning`s. They don't affect the functionality of SAPP and everything should be working as intended.
268+
269+
----
270+
271+
**Problem**: I can't connect to the Web UI and it displays an error related to SSL. The SAPP server log displays a bunch of `400 Bad Request` error codes
272+
273+
**Solution**: Make sure you are visiting [`http://localhost:5000`](http://localhost:5000) and not `https://localhost:5000`
274+
255275
----
256276
**Problem**: If your SAPP server shows `404 Not found` and the webpage shows `The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.`
257277

@@ -277,17 +297,12 @@ Checking which issues SAPP imported - you should expect the following lines to a
277297
```
278298

279299
----
280-
**Problem**: `pyre analyze --no-verify` exits with error `ƛ Uncaught exception: (Invalid_argument "~/.venvs/pysa/lib/pyre_check/typeshed/stdlib/zlib.pyi is not a directory")`
300+
**Problem**: The issues on SAPP Web UI have boxes with `No file found for filename.py`, so I cannot see the source code related to the trace for my issues
281301

282-
**Solution**: Delete your virtual environment and recreate your virtual environment by following the steps in the [Initial configuration](#initial-configuration) section
302+
**Solution**: Try passing the path to your project source code with `--source-directory` to `sapp server`
283303
```shell
284-
(pysa) $ deactivate
285-
$ rm -rf ~/.venvs/pysa
304+
(pysa) $ sapp server --source-directory path/to/project_source_code
286305
```
287-
----
288-
**Problem**: `pyre init` shows `ƛ Source directory path/to/dir does not exist. Be sure the source path is relative to the import_root`.
289-
290-
**Solution**: You will need to manually update `source_directories` in `.pyre_configuration`. Refer to [Pyre Global configuration section](configuration.md#the-global-configuration) to set up `source_directories`.
291306

292307
----
293308
**Problem**: Pysa still doesn't work despite trying everything above

0 commit comments

Comments
 (0)