Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full rust rewriting and new functionnalities #30

Merged
merged 68 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
930f9fa
Some optimisations and more tests
LeChatP Jul 29, 2023
e36dd34
Lets add some broken functionnalities
LeChatP Aug 20, 2023
0bdaf43
Reorganisation
LeChatP Aug 21, 2023
52fc92a
Regrouped into a simplified architecture
LeChatP Aug 21, 2023
eb57fcd
tests OK
LeChatP Aug 22, 2023
89ec38a
clap is dumb
LeChatP Aug 22, 2023
3168603
timestamp is working + format + clean project
LeChatP Aug 22, 2023
3a84af4
adding Separation of duties functionnality
LeChatP Aug 22, 2023
b90a368
add static separation of duties for sr program
LeChatP Aug 22, 2023
3d4539e
add Least privilege between parent and child roles
LeChatP Aug 22, 2023
7ac924e
add tests
LeChatP Aug 23, 2023
505d4f8
Lets test workflows
LeChatP Aug 23, 2023
6b5afa0
add sudo on build
LeChatP Aug 23, 2023
cbda511
timeout fix + order comparison fix
LeChatP Aug 23, 2023
9b2f22a
Whereis cargo
LeChatP Aug 24, 2023
f14535f
install cargo generally
LeChatP Aug 24, 2023
1ac6e8c
case error
LeChatP Aug 24, 2023
c48148c
quality gates workflow
LeChatP Aug 24, 2023
de6b1e8
better quality workflow
LeChatP Aug 24, 2023
e2f55d1
permission issue
LeChatP Aug 24, 2023
f0107c7
better quality and split audit
LeChatP Aug 24, 2023
be670db
format
LeChatP Aug 24, 2023
f2a647e
clippy fix and add tests
LeChatP Aug 24, 2023
6a58fb2
fix test workflow
LeChatP Aug 24, 2023
ab18aaf
grcov is not a component
LeChatP Aug 24, 2023
cceb30d
force format
LeChatP Aug 24, 2023
170559e
Fix CStr
LeChatP Aug 24, 2023
ef55b37
test and fix partial order comparison
LeChatP Aug 25, 2023
bcb40bd
Format Rust code using rustfmt
github-actions[bot] Aug 25, 2023
c6a95b9
Remove unused impl
LeChatP Aug 25, 2023
059c0b1
More tests and less dead code
LeChatP Aug 25, 2023
65cd5be
Merge branch 'develop' of github.com:LeChatP/RootAsRole into develop
LeChatP Aug 25, 2023
e01f9b5
fmt
LeChatP Aug 25, 2023
8ec690f
add debug on tests
LeChatP Aug 25, 2023
130d0e5
wrong env var
LeChatP Aug 25, 2023
bcfd08b
add more tests
LeChatP Aug 26, 2023
2415cca
clippy
LeChatP Aug 26, 2023
d7cb500
disable clippy for generated file
LeChatP Aug 26, 2023
c93fec5
better handle up/downgrade
LeChatP Aug 26, 2023
1344641
migration and denied capabilities
LeChatP Aug 26, 2023
cd601e3
fix recursion
LeChatP Aug 26, 2023
8e5776a
Format Rust code using rustfmt
github-actions[bot] Aug 26, 2023
d340e2c
stop audit every time.
LeChatP Aug 26, 2023
0c73fb8
fix version migration
LeChatP Aug 26, 2023
2fefbb2
Format Rust code using rustfmt
github-actions[bot] Aug 26, 2023
38a1552
Some logical bugs fixed
LeChatP Aug 27, 2023
403f252
Merge branch 'develop' of github.com:LeChatP/RootAsRole into develop
LeChatP Aug 27, 2023
4a3b2c9
fmt
LeChatP Aug 27, 2023
35b0b1d
remove descriptions.rs
LeChatP Aug 27, 2023
b0fd0ed
capable Rust rewriting
LeChatP Aug 29, 2023
a27c53e
unify version display
LeChatP Aug 29, 2023
768f3e4
Format Rust code using rustfmt
github-actions[bot] Aug 29, 2023
4788bc7
better capable install integration
LeChatP Aug 29, 2023
cc04e80
Format Rust code using rustfmt
github-actions[bot] Aug 29, 2023
c9018e6
configure update
LeChatP Aug 29, 2023
c9a5d16
Test add cargo to PATH
LeChatP Aug 29, 2023
0982d29
fix PATH github Actions
LeChatP Aug 29, 2023
96e6ec8
compiled root cargo binaries to /usr/bin
LeChatP Aug 29, 2023
4e9e8b0
does in same task works
LeChatP Aug 29, 2023
e6a481c
wildcard does not work in gha
LeChatP Aug 29, 2023
0763006
first code-level documentation commit
LeChatP Aug 29, 2023
7935346
first book commit
LeChatP Aug 29, 2023
3b6dd1a
Format Rust code using rustfmt
github-actions[bot] Aug 29, 2023
a93aad7
first initiation for logging feature.
LeChatP Aug 30, 2023
b0efffd
Merge branch 'develop' of github.com:LeChatP/RootAsRole into develop
LeChatP Aug 30, 2023
e9b2d3d
fmt
LeChatP Aug 30, 2023
1681100
change readme
LeChatP Aug 30, 2023
952c901
remove codacy which is now useless
LeChatP Aug 30, 2023
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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
32 changes: 32 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Audit

on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
schedule:
- cron: '0 0 * * *'

jobs:

rust-quality-gate:
name: Rust Quality Gate
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
profile: minimal
toolchain: stable
components: clippy
override: true

- name: Cargo audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
68 changes: 11 additions & 57 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,15 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
DOCKER: 1
steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v3
- name: Update version
run: sudo apt-get update
- name: Install Dependencies
run: sudo ./configure.sh -yd
- name: Configure PAM
run: |
sudo bash -c 'echo "#%PAM-1.0
auth [success=1 default=ignore] pam_permit.so
auth requisite pam_permit.so
auth required pam_permit.so
account [success=1 default=ignore] pam_permit.so
account requisite pam_permit.so
account required pam_permit.so
session [success=1 default=ignore] pam_permit.so
session requisite pam_permit.so
session required pam_permit.so" | tee /etc/pam.d/sr'
- name: Build Project
run: sudo -E make -e install
- name: Run Project
run: sr -h
- name: Print capabilities with sr
run: sr cat /proc/self/status
rust-build:
runs-on: ubuntu-latest
env:
working-directory: "role-manager"
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: rustup update
run: rustup update
- name: cargo version
run: cargo version
- name: Update version
run: sudo apt-get update
- name: Install Dependencies
run: sudo ./configure.sh -yd
sudo ./configure.sh -yd
sudo cp /root/.cargo/bin/bpf-linker /usr/bin/
echo "/home/runner/.cargo/bin" >> $GITHUB_PATH
- name: Configure PAM
run: |
sudo bash -c 'echo "#%PAM-1.0
Expand All @@ -68,24 +31,15 @@ jobs:
session [success=1 default=ignore] pam_permit.so
session requisite pam_permit.so
session required pam_permit.so" | tee /etc/pam.d/sr'
- name: Install sr tool
run: sudo -E make -e install
env:
DEBUG: 1
- name: Add read access on config on rootasrole... Because Github Actions...
run: sudo chmod a+r /etc/security/rootasrole.xml
- name: print config
run: |
sr cat /etc/security/rootasrole.xml
run: cat /etc/security/rootasrole.xml
- name: getenv
run: env
- name: sr getenv
run: sr env
- name: Print capabilities with sr
run: sr cat /proc/self/status
- name: Build Project
run: cargo build --release
working-directory: ${{ env.working-directory }}
- name: Run Project
run: cargo run --release -- -h
working-directory: ${{ env.working-directory }}
- name: Install Project
run: sudo -E make -e install
- name: Run Sr
run: /usr/bin/sr -h
- name: Run Chsr
run: /usr/bin/chsr -h
112 changes: 15 additions & 97 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,116 +21,34 @@ on:
branches:
- 'main'

permissions:
contents: read

jobs:
codacy-security-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v3

# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647

# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
rust-quality-gate:
name: Rust Quality Gate
env:
working-directory: "role-manager"
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
- name: Install Rust toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true

- name: Build code
run: cargo build --all --release
working-directory: ${{ env.working-directory }}

- name: Install required cargo
run: cargo install clippy-sarif sarif-fmt

- name: Run rust-clippy
run:
cargo clippy
--all-features
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
continue-on-error: true
working-directory: ${{ env.working-directory }}

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{ env.working-directory }}/rust-clippy-results.sarif
wait-for-processing: true
- name: Install Dependencies
run: sudo ./configure.sh -yd

rust-format:
name: Rust Formatting Gate
env:
working-directory: "role-manager"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
# if pull request review only
- uses: mbrobbel/rustfmt-check@master
with:
toolchain: stable
override: true
- name: Build code
run: cargo build --all --release
working-directory: ${{ env.working-directory }}
- name: Format code with Rustfmt
run: cargo fmt --all -- --check
working-directory: ${{ env.working-directory }}
token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true #TODO: remove this line when rustfmt-check is fixed

rust-security:
name: Rust Security Gate
env:
working-directory: "role-manager"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
- uses: actions-rs/clippy-check@v1
with:
toolchain: stable
override: true

- name: Cargo audit
run: cargo audit --json | tee cargo-audit.json
working-directory: ${{ env.working-directory }}
id: cargo-audit
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
46 changes: 6 additions & 40 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,8 @@ on:
- 'main'

jobs:
criterion:
runs-on: ubuntu-latest

env:
TEST: 1
DEBUG: 1
COV: 1

steps:
- uses: actions/checkout@v2

- name: Update version
run: sudo apt-get update
- name: Install Dependencies
run: sudo -E ./configure.sh
- name: Build Unit Tests
run: make -e build_unit_test
- name: Run Unit Tests
run: ./bin/unit_test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
gcov: true
rust-coverage:
runs-on: ubuntu-latest
needs: criterion # cannot upload concurrenlty to codecov
env:
working-directory: role-manager
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -47,37 +19,31 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: llvm-tools-preview
override: true

- name: Install grcov
working-directory: ${{ env.working-directory }}
run: cargo install grcov

- name: Install llvm-tools-preview
working-directory: ${{ env.working-directory }}
run: rustup component add llvm-tools-preview

- name: Build project for generating version.rs
working-directory: ${{ env.working-directory }}
run: cargo build
- name: Install Dependencies
run: sudo ./configure.sh -yd

- name: run tests with coverage
working-directory: ${{ env.working-directory }}
run: cargo test
env:
RUST_LOG: debug
CARGO_INCREMENTAL: 0
RUSTFLAGS: '-Cinstrument-coverage'
LLVM_PROFILE_FILE: 'cargo-test-%p-%m.profraw'
continue-on-error: true

- name: generate report
working-directory: ${{ env.working-directory }}
run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/debug/role-manager.lcov
run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/debug/rootasrole.lcov

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: role-manager/target/debug/role-manager.lcov
file: target/debug/rootasrole.lcov
flags: unittests
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
*.su
*.idb
*.pdb
*.sarif

# Kernel Module Compile Results
*.mod*
Expand All @@ -60,7 +61,7 @@ bin/
# Hidden folders (for Linux IDE)
/.idea/
*target/
version.rs
*/src/xml_version.rs

# Rust crates
Cargo.lock
8 changes: 8 additions & 0 deletions .vscode/gdb_root.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
SELF_PATH=$(realpath -s "$0")

if [[ "$SUDO_ASKPASS" = "$SELF_PATH" ]]; then
zenity --password --title="$1"
else
exec env SUDO_ASKPASS="$SELF_PATH" sudo -A /usr/bin/gdb $@
fi
Loading
Loading