diff --git a/.github/workflows/action-test.yaml b/.github/workflows/action-test.yaml new file mode 100644 index 0000000..c4e4a6d --- /dev/null +++ b/.github/workflows/action-test.yaml @@ -0,0 +1,27 @@ +on: + push: + branches: [initial-prototype] + pull_request: + branches: [initial-prototype] + +name: RcppDeepState + +jobs: + RcppDeepState: + runs-on: ubuntu-latest + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v2 + + - uses: actions/checkout@v2 # checkout 'FabrizioSandri/RcppDeepState' containing the 'testSAN' package + with: + repository: FabrizioSandri/RcppDeepState + path: RcppDeepState + + - name: Analyze the package with RcppDeepState # run RccpDeepState on 'testSAN' + uses: ./ + with: + location: /RcppDeepState/inst/testpkgs/testSAN diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1f0c9a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:latest + +# setup zoneinfo +RUN ln -snf /usr/share/zoneinfo/$INPUT_ZONEINFO /etc/localtime && echo $INPUT_ZONEINFO > /etc/timezone + +RUN apt update +RUN apt install -y build-essential gcc-multilib g++-multilib cmake python3-setuptools python3-dev libffi-dev clang valgrind libcurl4-gnutls-dev libxml2-dev libssl-dev wget +RUN apt install -y r-base + +# Copy the files to the root filesystem of the container +COPY src/entrypoint.sh /entrypoint.sh +COPY src/analyze_package.R /analyze_package.R +RUN chmod +x /entrypoint.sh + +# Executes `entrypoint.sh` when the Docker container starts up +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index e092ac0..20ebd34 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,39 @@ RcppDeepState is a fuzz testing library made as a composition of three tools: Rc * Link to [RcppDeepState](https://github.com/FabrizioSandri/RcppDeepState) ## Inputs - +- **location** (default value: `/`) - Relative path under `$GITHUB_WORKSPACE` that contains the package that needs to be analyzed. Default uses the `/` location relative to `$GITHUB_WORKSPACE`, that is `$GITHUB_WORKSPACE`. ## Outputs -## Example usage +## Usage +Before running this GitHub Action it's mandatory to run the [actions/checkout](https://github.com/actions/checkout) Action to check-out the repository containing the Rcpp package that needs to be analyzed. Remember that you must specify the parameter `location` for this action if you use the `path` argument for `actions/checkout` or if the package that has to be analyzed isn't located in the root of the repository, otherwise RcppDeepState won't be able to find your package. + +```yaml +- uses: actions/checkout@v2 + +- uses: FabrizioSandri/RcppDeepState-action + with: + # Relative path under $GITHUB_WORKSPACE where the package that needs to be + # analyzed is located. + # Default: / + location: '' +``` + +#### Basic example +This simple workflow can be run inside a repository containing a Rcpp-based package, stored in the root of the repository. +```yaml +- uses: actions/checkout@v2 + +- uses: FabrizioSandri/RcppDeepState-action +``` + +#### Custom path example +Assume the package you wish to test is not at the repository's root, but rather, for instance, in the `/inst/testpkgs/testSAN` subdirectory. In this case, the package can be analyzed specifying the `location` parameter. + +```yaml +- uses: actions/checkout@v2 + +- uses: FabrizioSandri/RcppDeepState-action + with: + location: '/inst/testpkgs/testSAN' +``` \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..e4814c0 --- /dev/null +++ b/action.yml @@ -0,0 +1,13 @@ +name: 'RcppDeepState' +author: 'Fabrizio Sandri' +description: 'This Action runs RcppDeepState in any Rcpp-based projects hosted on GitHub' +inputs: + location: + description: 'Location of the package if not in the root of the repository' + required: false + default: '/' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.location }} \ No newline at end of file diff --git a/src/analyze_package.R b/src/analyze_package.R new file mode 100644 index 0000000..51b38e4 --- /dev/null +++ b/src/analyze_package.R @@ -0,0 +1,10 @@ +require(RcppDeepState) + +GitHub_workspace <- Sys.getenv("GITHUB_WORKSPACE") +location <- Sys.getenv("INPUT_LOCATION") + +deepstate_harness_compile_run(file.path(GitHub_workspace, location)) +result <- deepstate_harness_analyze_pkg(file.path(GitHub_workspace, location)) + +print(result) +print(result$logtable) \ No newline at end of file diff --git a/src/entrypoint.sh b/src/entrypoint.sh new file mode 100755 index 0000000..03d0c1f --- /dev/null +++ b/src/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +### Dependencies installation +Rscript -e 'install.packages("devtools", repos="https://cloud.r-project.org")' +Rscript -e 'devtools::install_github("FabrizioSandri/RcppDeepState")' + +# disable optimization options +mkdir -p ~/.R +echo -e "CXXFLAGS = \nCXX11FLAGS = \nCXX14FLAGS = \nCXX17FLAGS = \nCXX20FLAGS = \n" > ~/.R/Makevars + +### Start the analysis +echo "RcppDeepState analysis started" + +Rscript "/analyze_package.R" + +echo "RcppDeepState analysis completed"