From 3df605fdd8de369fce27f2eae5134ce68e06af16 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Wed, 29 Jun 2022 09:57:55 +0200 Subject: [PATCH 01/12] basic action.yml structure --- action.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..478bfbd --- /dev/null +++ b/action.yml @@ -0,0 +1,6 @@ +name: 'RcppDeepState' +author: 'Fabrizio Sandri' +description: 'This Action runs RcppDeepState in any Rcpp-based projects hosted on GitHub' +runs: + using: 'docker' + image: 'Dockerfile' \ No newline at end of file From d61188d4cdc6a015bd91264463ab38610246e9ea Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Wed, 29 Jun 2022 10:30:28 +0200 Subject: [PATCH 02/12] Dockerfile and entrypoint --- Dockerfile | 8 ++++++++ src/entrypoint.sh | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 Dockerfile create mode 100755 src/entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..de54dc4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:latest + +# Copy the entrypoint to the root filesystem of the container +COPY src/entrypoint.sh /entrypoint.sh +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/src/entrypoint.sh b/src/entrypoint.sh new file mode 100755 index 0000000..537c73f --- /dev/null +++ b/src/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "RcppDeepState" + From a62598ab6e4dc89f8933e875e503088158824b05 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Wed, 29 Jun 2022 14:03:24 +0200 Subject: [PATCH 03/12] Dockerfile dependencies --- Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index de54dc4..4eb198a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,13 @@ FROM ubuntu:latest -# Copy the entrypoint to the root filesystem of the container +# 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 z3 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 RUN chmod +x /entrypoint.sh From ee1b1d3e54bf49dbfbcc5f8059298b5aba15631e Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Wed, 29 Jun 2022 14:06:59 +0200 Subject: [PATCH 04/12] devtools installation of RcppDeepState --- src/entrypoint.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 537c73f..27c2193 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -1,4 +1,5 @@ #!/bin/bash -echo "RcppDeepState" - +### Dependencies installation +Rscript -e 'install.packages("devtools", repos="https://cloud.r-project.org")' +Rscript -e 'devtools::install_github("FabrizioSandri/RcppDeepState")' From bb0a85a19d74b3866aa1894dd42381998416c141 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Wed, 29 Jun 2022 19:18:15 +0200 Subject: [PATCH 05/12] disable optimization options --- src/entrypoint.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 27c2193..ae62b04 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -3,3 +3,7 @@ ### 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 From 7a12dfee7f0d5963a7124e37036372cc924e8bc2 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Thu, 30 Jun 2022 10:24:38 +0200 Subject: [PATCH 06/12] dependencies update --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4eb198a..aab6086 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:latest 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 z3 clang valgrind libcurl4-gnutls-dev libxml2-dev libssl-dev wget +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 From 00075e03bda645a501b1406753969369d140b047 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Thu, 30 Jun 2022 10:25:22 +0200 Subject: [PATCH 07/12] set up the R script to run the analysis of the package --- Dockerfile | 1 + src/analyze_package.R | 2 ++ src/entrypoint.sh | 7 +++++++ 3 files changed, 10 insertions(+) create mode 100644 src/analyze_package.R diff --git a/Dockerfile b/Dockerfile index aab6086..1f0c9a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ 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 diff --git a/src/analyze_package.R b/src/analyze_package.R new file mode 100644 index 0000000..4e8e2de --- /dev/null +++ b/src/analyze_package.R @@ -0,0 +1,2 @@ +require(RcppDeepState) + diff --git a/src/entrypoint.sh b/src/entrypoint.sh index ae62b04..03d0c1f 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -7,3 +7,10 @@ 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" From d8a42bbc11c688f16637b640f5becb7b36e10987 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Thu, 30 Jun 2022 14:10:29 +0200 Subject: [PATCH 08/12] run RcppDeepState analysis --- src/analyze_package.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/analyze_package.R b/src/analyze_package.R index 4e8e2de..4da9361 100644 --- a/src/analyze_package.R +++ b/src/analyze_package.R @@ -1,2 +1,9 @@ require(RcppDeepState) +GitHub_workspace <- Sys.getenv("GITHUB_WORKSPACE") + +deepstate_harness_compile_run(GitHub_workspace) +result <- deepstate_harness_analyze_pkg(GitHub_workspace) + +print(result) +print(result$logtable) \ No newline at end of file From d5fa71de798aaeacbe1921c2d73d24d8a7821be7 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Fri, 1 Jul 2022 11:45:45 +0200 Subject: [PATCH 09/12] package location input --- action.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 478bfbd..e4814c0 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +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' \ No newline at end of file + image: 'Dockerfile' + args: + - ${{ inputs.location }} \ No newline at end of file From 7b5adf7e320b95e9f4236830b04de9f479908d56 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Fri, 1 Jul 2022 11:49:02 +0200 Subject: [PATCH 10/12] analyze the package considering the location parameter --- src/analyze_package.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/analyze_package.R b/src/analyze_package.R index 4da9361..51b38e4 100644 --- a/src/analyze_package.R +++ b/src/analyze_package.R @@ -1,9 +1,10 @@ require(RcppDeepState) GitHub_workspace <- Sys.getenv("GITHUB_WORKSPACE") +location <- Sys.getenv("INPUT_LOCATION") -deepstate_harness_compile_run(GitHub_workspace) -result <- deepstate_harness_analyze_pkg(GitHub_workspace) +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 From 32d35d37ddde8c85ed2a82673234535a077ae95f Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Fri, 1 Jul 2022 13:48:22 +0200 Subject: [PATCH 11/12] Test workflow --- .github/workflows/action-test.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/action-test.yaml 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 From 627a9dd3e058d11f5973f9eac14117d411f4f122 Mon Sep 17 00:00:00 2001 From: Fabrizio Sandri Date: Fri, 1 Jul 2022 15:39:50 +0200 Subject: [PATCH 12/12] README update --- README.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) 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