Code Monkey home page Code Monkey logo

privacy-tech-lab / privacyflash-pro Goto Github PK

View Code? Open in Web Editor NEW
152.0 12.0 14.0 50.19 MB

Generate a privacy policy for your iOS app quickly and automatically

Home Page: https://privacytechlab.org/

License: MIT License

Swift 62.26% Objective-C 1.49% Ruby 0.10% HTML 11.29% CSS 0.44% JavaScript 3.38% Python 1.43% C 19.48% Shell 0.14%
privacy-policy ios-swift software-engineering software-development mobile-development code-analysis privacy-tech ccpa

privacyflash-pro's Introduction

GitHub release (latest by date) GitHub Release Date GitHub last commit GitHub issues GitHub closed issues GitHub GitHub watchers GitHub Repo stars GitHub forks GitHub sponsors


PrivacyFlash Pro

To easily run PrivacyFlash Pro get the latest packaged release.

Learn more about PrivacyFlash Pro in our research paper (BiBTeX).

PrivacyFlash Pro analyzes the code of iOS Swift apps and their libraries to generate privacy policies. With PrivacyFlash Pro we intend to help developers creating privacy policies for their apps and make the apps' privacy practices more transparent to users.

PrivacyFlash Pro covers provisions of the following laws:

  • California Consumer Privacy Act (CCPA)
  • California Online Privacy Protection Act (CalOPPA)
  • Children's Online Privacy Protection (COPPA)
  • General Data Protection Regulation (GDPR).

PrivacyFlash Pro is an academic research project. It was designed and developed by David Baraka (@davebaraka), Rafael Goldstein (@rgoldstein01), Sarah Jin (@sj-in), and Sebastian Zimmeck (@SebastianZimmeck) of the privacy-tech-lab. Kuba Alicki (@kalicki1) wrote the unit tests.

1. Installing, Running, and Packaging PrivacyFlash Pro
2. Demo Video
3. Get Involved
4. Testing
5. Files and Directories in this Repo
6. Third Party Libraries
7. Thank You!

1. Installing, Running, and Packaging PrivacyFlash Pro

You can install and run PrivacyFlash Pro from the packaged release or from the source files. You can also create a new packaged version of PrivacyFlash Pro.

Installing from the Packaged Release

You will find the releases of PrivacyFlash Pro in the releases section (you may need to allow downloading the zip file in your browser settings, e.g., under Google Chrome's Downloads settings). Unzip the downloaded privacyflash-pro.zip and then click the PrivacyFlash Pro icon. You will have to agree to open PrivacyFlash Pro in your macOS security settings. After a few seconds PrivacyFlash Pro should run in your default browser.

Installing from the Source Files

  1. Ensure that Python 3 is installed. PrivacyFlash Pro does not support Python 2. You can check in your terminal if you have Python 3 installed by running python3. You can get Python 3 on the official Python website.

  2. Clone this repo by cding into the directory in which you want to store PrivacyFlash Pro and run git clone [email protected]:privacy-tech-lab/privacyflash-pro.git.

  3. Strongly Recommended: Create and activate a Python virtual environment, pfp-venv, with python3 -m venv pfp-venv, and run it with source pfp-venv/bin/activate (assuming that you are using the default shell). Ensure that your virtual environment is outside of the privacyflash-pro directory to avoid git tracking.

  4. cd into the privacyflash-pro/policygenerator directory. If you are using a Python virtual environment, run pip3 install -r requirements.txt. Otherwise, run pip3 install --user -r requirements.txt. If you get an error, run pip3 install -r requirements.txt. If you still get an error, run sudo pip3 install -r requirements.txt.

  5. Run PrivacyFlash Pro with python3 app.py.

Running

Using PrivacyFlash Pro's directory navigation, navigate to your iOS Swift project directory (the directory that contains your .xcodeproj), and click OK to start the analysis. Depending on the size of your codebase, the analysis results should be available within a minute. You will now be guided through a wizard. Once you have finalized the wizard questionnaire, you can export the privacy policy for your app.

You can test PrivacyFlash Pro on the projects in the iOS-sample-projects. For example, you can analyze the AdColony sample project. Start PrivacyFlash Pro, in your browser navigate to the AdColony directory using PrivacyFlash Pro's directory navigation, and click OK to start the analysis. The analysis results should be available within a minute.

If your browser does not connect to the localhost, try disabling any antivirus software (e.g., eset) that you may be running.

PrivacyFlash Pro analyzes iOS app source code in Swift and its integrated third party libraries in Swift and Objective-C. The library analysis works for uncompiled and compiled libraries. PrivacyFlash Pro does not analyze iOS app source code in Objective-C.

Packaging

You can also create a new packaged version of PrivacyFlash Pro. After successfully installing and running from source, run python3 package.py within the privacyflash-pro/policygenerator directory. A zipped file containing a macOS distributable app will be generated in the privacyflash-pro/policygenerator/dist directory.

Note: If you are using a Python virtual environment, as we recommend, run python3 package.py after activating the environment.

Note: If packaging for public distribution, remember to update the version number in privacyflash-pro/policygenerator/interface/index.html and privacyflash-pro/policygenerator/package.py. Also, please identify to your users that you packaged the version and that the version is not official.

If you experience errors packaging or running the packaged app, try updating the dependency pyinstaller by running pip3 install pyinstaller -U and then run the packaging script again.

2. Demo Video

Watch the Demo

3. Get Involved

PrivacyFlash Pro is from the people for the people. Everyone can contribute. In particular, feel free to open a pull request to add additional privacy practices and third party libraries. If you have other ideas or feedback, let us know. We are looking forward to hear from you!

Privacy Practice Analysis

The specification for the privacy practice analysis is contained in policygenerator/spec/privacy_practices.yaml. PrivacyFlash Pro flags a privacy practice in an app or a library if it identifies the use of a relevant API, i.e., all of the following are present for the app or a library:

  • PLIST value (e.g., NSLocationWhenInUseUsageDescription)
  • FRAMEWORK import (e.g., CoreLocation)
  • CLASS instantiation (e.g., CLLocationManager)
  • AUTHORIZATION METHOD call (e.g., requestWhenInUseAuthorization)

For the analysis of the app code, the AUTHORIZATION METHOD can also be in a library as long as there is ADDITIONAL EVIDENCE (e.g., startUpdatingLocation) in the app code. Vice versa, for the analysis of a library, the AUTHORIZATION METHOD can also be in the app code as long as there is ADDITIONAL EVIDENCE (e.g., startUpdatingLocation) in the library.

Also, for some practices, for example, Health, an ENTITLEMENT (e.g., com.apple.developer.healthkit) is required. For more details see the privacy_practices.yaml.

Third Party Library Analysis

PrivacyFlash Pro identifies any library integrated in the analyzed app. The specification for the third party library analysis is contained in policygenerator/spec/third_parties.yaml. PrivacyFlash Pro is using this specification for determining the purpose of a library. A library name is given by its name on CocoaPods. For example, AdColony has the purpose Advertising. PrivacyFlash Pro currently identifies the purposes of 300 libraries using the following purpose categories:

  • Authentication
  • Advertising
  • Analytics
  • Developer Support
  • Payment Processing
  • Social Network Integration

Note that even if a library is is not contained in policygenerator/spec/third_parties.yaml, PrivacyFlash Pro still analyzes its files contained in a project. However, you will have to enter the purpose of the library manually in the privacy policy you are generating.

4. Testing

Our unit tests for PrivacyFlash Pro have been built with the Python unittest framework. In order to run the built-in tests for PrivacyFlash Pro, use python3 -m unittest from within the root directory of your local copy of this repo.

5. Files and Directories in this Repo

  • The latest release of PrivacyFlash Pro is contained in the releases section.
  • iOS-sample-projects: Sample projects for PrivacyFlash Pro to analyze and test.
  • policygenerator/: Contains the code of PrivacyFlash Pro.
  • policygenerator/app.py: Main entry point for generating a privacy policy.
  • policygenerator/package.py: Script to create a distributable package of PrivacyFlash Pro.
  • policygenerator/interface: Contains all code related to the user interface for displaying the policy to the user.
  • policygenerator/spec: Third party and privacy practices specifications.
  • policygenerator/spec/privacy_practices.yaml: Contains the specification for detecting privacy practice usage.
  • policygenerator/spec/third_parties.yaml: Contains the specification for ad networks and other third party libraries.
  • policygenerator/src/analysis.py: The module for analyzing the project looks for instances of privacy practice usage.
  • policygenerator/src/configure_data.py: Bridge between the Python code and the Javascript code for the UI; configures the results from the generator engine to proper json files/objects to be used for the UI.
  • policygenerator/src/constants.py: The constants class is used internally to identify a privacy practice by an index value.
  • policygenerator/src/evidence.py: The evidence class is used for keeping track of privacy practice usages in an app's files.
  • policygenerator/src/privacy_practices.py: Loads data from the app project to be analyzed.
  • policygenerator/requirements.txt: Dependencies of PrivacyFlash Pro.

6. Third Party Libraries

PrivacyFlash Pro uses the following third party libraries. We thank the developers.

7. Thank You!

We would like to thank our supporters!


Financial support provided by Wesleyan University and the Anil Fernando Endowment.

Wesleyan University Logo

Conclusions reached or positions taken are our own and not necessarily those of our financial supporters, its trustees, officers, or staff.

privacy-tech-lab logo

privacyflash-pro's People

Contributors

davebaraka avatar dependabot[bot] avatar kalicki1 avatar kubagithub avatar rgoldstein01 avatar sebastianzimmeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

privacyflash-pro's Issues

Add unit tests

We would like to add some testing code. @kalicki1 will add a few unit tests to start. Especially, let's test PFP's analysis functionality in analysis.py and privacy_practices.py.

A good starting point are Python's pytest and unittest frameworks. Here is a tutorial that covers both.

For the time being, we can just focus on passing tests and not worry about failing tests. As @rgoldstein01 mentioned, for example, if you want to test whether a function recognizes certain keywords in files, you can create some dummy input that represents an app file (e.g., a text file with certain keywords).

You can create a new directory tests under privacyflash-pro and include your files there.

(cc'ing @davebaraka, @pakaelbling)

Prepare, test, and release v1.0.2

@rgoldstein01, can you prepare, test and release a new version? Here are instructions that @davebaraka provided for the previous release:

I packaged the generator (attached below). I am running Mac OS Version 10.15 (19A583).

I was able to package the generator by first creating and activating a python virtual environment. Then, installing the dependencies for the generator in the virtual environment as well as Pyinstaller. To package the generator, run python3 -m eel app.py interface --onefile --noconsole --add-data "data:data" in the policygenerator directory with all the python files. The packaged generator should appear in a /dist folder.

Packaging the generator may still work without the virtual environment, but not recommended, at least for production.

An app.spec file will also appear in the policygenerator directory. This file contains the configuration settings for PyInstaller to package the python script. So, running python3 -m PyInstaller app.spec will also appropriately package the generator. You can modify this file to change the name of the packaged script, add an icon, etc. Spec Files

Originally posted by @davebaraka in https://github.com/privacy-tech-lab/privacyflash-pro-dev/issues/10#issuecomment-541496215

Set Dependabot alerts so that unused dependencies are omitted

@danielgoldelman, once you have time, could you look into whether it is possible to set the Dependabot alerts for this repo to exclude certain packages or certain directories or files of the repo?

The issue is the following: there are sample iOS projects in this repo, and we keep getting security alerts for the dependencies that those projects are using. However, the code of the projects is never run; we just use those project to run our own analyzer on. It is a bit annoying to get these Dependabot security alerts, especially, as there are quite a large number of the dependencies for the Firefox sample project. Here are some screenshots how these alerts look like:

Screen Shot 2021-05-10 at 7 25 38 PM

Screen Shot 2021-05-10 at 7 26 12 PM

There seems to be a way to ignore certain packages gitignore-style with ignored_updates.

This is a one-off task. It would be great if you could look into it.

Add iOS 14 changes per WWDC 2020

At WWDC 2020 Apple announced some new privacy features in iOS 14, which we should account for.

  • There seems to be a new location API that allows apps to only access the approximate location of a device within a certain radius.
  • Apps need to have permission to track users across devices. Maybe, this will be a new permission.
  • App developers will be asked to provide which permissions (and other resources?) their apps are using. As I understand, this information has to be provided by the developer manually and will be displayed on an app's App Store page in a nutrition label-like format. I do not think that we need to implement any new features here. (Maybe, we can think about generating a label that developers can create and paste in Apple's form. This would be essentially a subset of what we analyze. So, in addition of generating a privacy policy, developers could also generate the label.)

All in all, these news are making a pretty good case for PrivacyFlash Pro.

(cc'ing @kalicki1)

Microsoft ApplicationInspector integration

I just came across the Microsoft ApplicationInspector. It looks like an interesting project. In their words, it is a "source code analysis tool that helps identify and surface well-known features and other interesting characteristics of source code to aid in determining what the software is or what it does." It covers Swift and Objective-C and from the readme it seems that it can analyze whether an app uses sensitive data or cloud services, for example. Maybe, we can integrate it into PrivacyFlash Pro. For the time being, this is a long shot, but may be worthwhile to revisit.

Include packaging instructions in readme

It would be good for me to know how to package PrivacyFlash Pro. @davebaraka, perhaps you can include instructions how you are doing it in a separate section in the readme. It is not urgent that we do this now. February 2021 would be a good time when we are publishing a release in time for our paper.

(cc'ing @rgoldstein01)

Integration with testing framework

Another idea is to integrate PFP into some testing framework (maybe, even continuous integration). Every time the tests are run, privacy-relevant features that are added to the app or library code will be flagged, and developers will be alerted that the privacy policy was changed/needs to be changed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.