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

Other PR's merged + code improved + flow improved #168

Open
wants to merge 101 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
9196b79
add -P option, to pass the script via pipe instead of command line
fabio-brugnara Jun 2, 2023
a0cbfd9
modified untraceable() to avoid occasional freeze with zombie
fabio-brugnara Jun 2, 2023
9c77773
add support for python*
fabio-brugnara Jun 2, 2023
6242bf5
initialize pipe flag to 0
fabio-brugnara Jun 5, 2023
6dc86a0
Fix script file names containing spaces and other special characters.
ergoucao Sep 7, 2023
defa47b
Fix files with linting & formatting tools + spelling correction
mdeweerd Jan 5, 2024
d23e9a9
minor: Fix spelling require->requires
mdeweerd Jan 5, 2024
c5736c3
Improve format hinting
mdeweerd Jan 5, 2024
37b7189
Make script executable
mdeweerd Jan 5, 2024
727c60e
add install procedure for Debian and Ubuntu systems in the README
lb803 Jan 25, 2024
a280a4d
reword the 'Ubuntu-specific' heading to make it more specific
lb803 Jan 25, 2024
8dec142
add code block hinting for the Ubuntu PPA install procedure
lb803 Jan 25, 2024
5a3eb51
Fix memory leaks in write_c and eval_shell
ashamedbit Jan 28, 2024
4bd412e
Remove ash dependency
dviererbe Jul 16, 2024
c2c263a
ci: pre-commit & generate actions
mdeweerd Jan 5, 2024
6098fee
Spelling updates, regenerate man
mdeweerd Aug 11, 2024
72b3f92
Merge branch 'ci/precommit_generate' into memory-leak-fixes
mdeweerd Aug 11, 2024
26b90c7
Merge branch 'fix/linting' into integration/merge
mdeweerd Aug 11, 2024
dd622ea
Merge branch 'fix/spelling/man' into integration/merge
mdeweerd Aug 11, 2024
7a64c63
Merge branch 'pr157' into integration/merge
mdeweerd Aug 11, 2024
dc1a51c
Merge branch 'pr167' into integration/merge
mdeweerd Aug 11, 2024
80a813e
Merge branch 'pr164' into integration/merge
mdeweerd Aug 11, 2024
b37b159
Merge branch 'doc/format-hints' into integration/merge
mdeweerd Aug 11, 2024
3385b79
Add exceptions for test, and possibility to exclude cppchecks
mdeweerd Aug 11, 2024
6e5fe35
Exclude readability/casting because this is c-code
mdeweerd Aug 11, 2024
819b7ae
Ignore several external files for checks
mdeweerd Aug 11, 2024
dbbe389
Cleanup INSTALL
mdeweerd Aug 11, 2024
7791306
Cleanup .travis.yml
mdeweerd Aug 11, 2024
d62dd17
Add ci (replace travis)
mdeweerd Aug 11, 2024
53aad7e
ci: Github Action Generate Files
invalid-email-address Aug 11, 2024
684fa07
Fix cpplint/cppcheck
mdeweerd Aug 11, 2024
ab1b51d
Do test with sanitize on
mdeweerd Aug 11, 2024
a984bad
Do test with sanitize on
mdeweerd Aug 11, 2024
f9da88e
Also ignore Makefile.am for file formatting
mdeweerd Aug 11, 2024
52b7f6b
Sanitizer: stop the program when a leak is detected
mdeweerd Aug 11, 2024
9837b8d
Merge commit '52b7f6b' into integration/merge
mdeweerd Aug 11, 2024
be20a38
Avoid warning about not using the return value of setuid
mdeweerd Aug 11, 2024
7be5e33
Upgrade pandoc workflow
mdeweerd Aug 11, 2024
c61eb85
ci: Github Action Generate Files
invalid-email-address Aug 11, 2024
489e8dd
Add uncrustify configuration, apply it
mdeweerd Aug 12, 2024
ad89854
Merge branch 'integration/merge' of github.com:mdeweerd/shc into inte…
mdeweerd Aug 12, 2024
c067aff
Update executable bit for INSTALL
mdeweerd Aug 12, 2024
a1a4d20
Remove space after sizeof
mdeweerd Aug 12, 2024
7b6b7f5
Format code before merging
mdeweerd Aug 12, 2024
21e214e
Merge branch 'pr153' into integration/merge
mdeweerd Aug 12, 2024
7eee637
add test in ttest.sh for -P flag and python
fabio-brugnara Aug 12, 2024
b563090
Ignore developer name
mdeweerd Aug 12, 2024
d2cac42
Test pip & python
fabio-brugnara Aug 12, 2024
792260b
Allow skipping of tests
mdeweerd Aug 12, 2024
d233552
Fix memory leaks in generated program
mdeweerd Aug 12, 2024
60c86e0
Fix issue with flagging overflow
mdeweerd Aug 12, 2024
1e635da
Use unsigned to avoid runtime signed overflow notice & sprintf->snprintf
mdeweerd Aug 12, 2024
3871627
use unsigned in random generation to avoid sanitizer warning
fabio-brugnara Aug 12, 2024
ee754b8
add braces around break
fabio-brugnara Aug 12, 2024
9f3565a
Merge branch 'pr153' into integration/merge
mdeweerd Aug 13, 2024
714e922
add SHC_ARGV0 to environment
fabio-brugnara Aug 15, 2024
b3f9c99
added SHC_PID for safer handling of SHC_ARGV0
fabio-brugnara Aug 16, 2024
f4ff8e1
first partial draft of argv0 fix, only for *sh
fabio-brugnara Aug 16, 2024
6d4ebd0
Test $0 value
mdeweerd Aug 17, 2024
87f9485
second draft of argv0 fix, includes python, and put argv fix under op…
fabio-brugnara Aug 17, 2024
163b5f9
Add several test script to pre-commit checks
mdeweerd Aug 17, 2024
bd058ff
Duplicate strings before encryption to print unmangled args
mdeweerd Aug 17, 2024
219fbc3
Add flow (actions & test runs)
mdeweerd Aug 17, 2024
7ebbc2d
Merge branch 'argv0' of github.com:fabio-brugnara/shc into argv0
mdeweerd Aug 17, 2024
a834aa4
Disable sanitize run for fork evaluation
mdeweerd Aug 17, 2024
3d64ca3
Uncrustify before merge
mdeweerd Aug 17, 2024
1335cec
Uncrustify before merge
mdeweerd Aug 17, 2024
427259b
Merge branch 'argv0_with_pre' into argv0_test
mdeweerd Aug 17, 2024
b70a297
Set -0 option in tests
mdeweerd Aug 17, 2024
2dbcec6
Enable -0 option in tests
mdeweerd Aug 17, 2024
a2bc6ea
Enable -0 option in tests
mdeweerd Aug 17, 2024
997c3d0
fix typo in python3 DB
fabio-brugnara Aug 17, 2024
3f44476
add perl support (with -P forced)
fabio-brugnara Aug 17, 2024
729b1bd
Add shell name and option to test temporary path
mdeweerd Aug 17, 2024
52a17fc
Add shell name and option to test temporary path
mdeweerd Aug 17, 2024
accb0b8
Add timeout value to ci run
mdeweerd Aug 17, 2024
376a712
Add timeout value to ci run
mdeweerd Aug 17, 2024
e94567b
Fix timeout syntax & rename job
mdeweerd Aug 17, 2024
2d7abab
Extend tests with arguments with spaces and quotes, and fix tcsh and …
mdeweerd Aug 17, 2024
64c7824
fix sourcing of binary for *csh
fabio-brugnara Aug 18, 2024
de0a223
Solve $0 for zsh when using pipe
mdeweerd Aug 18, 2024
c649a87
Adjust test to not require forged $0 for rc and the pipe option
mdeweerd Aug 18, 2024
91ec8f9
fix minor oversight in shell list
fabio-brugnara Aug 18, 2024
3ed7c04
Merge branch 'argv0' into argv0_with_pre
mdeweerd Aug 18, 2024
aa84e8b
Merge branch 'argv0_with_pre' into argv0_test
mdeweerd Aug 18, 2024
e9ddf90
Remove temporary output for debug from ttest.sh
mdeweerd Aug 18, 2024
d713001
ci: Github Action Generate Files
invalid-email-address Aug 18, 2024
17b89be
Add dependabot configuration
mdeweerd Aug 18, 2024
521f8d4
Bump dorny/paths-filter from 2 to 3
dependabot[bot] Aug 18, 2024
be6edbe
Fix executable flag on generated files
mdeweerd Aug 18, 2024
ac0ca7a
Merge pull request #1 from mdeweerd/dependabot/github_actions/dorny/p…
mdeweerd Aug 18, 2024
cf91f8f
make forging of argv0 opt-out with -p, force -P for *csh
fabio-brugnara Aug 18, 2024
db31ddd
Change meaning of options -P -p. Added set of __file__ to python prea…
fabio-brugnara Aug 19, 2024
95bcb63
Update Changelog
mdeweerd Aug 19, 2024
ac7eccc
Merge branch 'argv0' into argv0_with_pre
mdeweerd Aug 19, 2024
9a9da5a
Merge branch 'argv0_with_pre' into integration/merge
mdeweerd Aug 19, 2024
aedbebe
Cleanup format of generated script
mdeweerd Aug 19, 2024
9ead41a
Extend tests to more options
mdeweerd Aug 19, 2024
85d658e
Update documentation
mdeweerd Aug 19, 2024
7b0337f
ci: Github Action Generate Files
invalid-email-address Aug 19, 2024
298b848
Avoid warning about unused return value of system() + doc
mdeweerd Aug 19, 2024
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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI

on: [push, pull_request]

jobs:
build-and-test:
# Normally runs in less than 50 seconds, but could stall because of test
timeout-minutes: 3
runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get update -q && sudo apt install -y dash bash ksh zsh tcsh csh rc

- name: Build and Test (with sanitize)
env:
SKIP: python2
run: |
SANITIZE="${SANITIZE} -fsanitize=address"
#SANITIZE="${SANITIZE} -fsanitize=thread"
SANITIZE="${SANITIZE} -fsanitize=leak"
SANITIZE="${SANITIZE} -fsanitize=undefined"
SANITIZE="${SANITIZE} -fsanitize=integer-divide-by-zero"
# SANITIZE="${SANITIZE} -fsanitize=vla-bound"
SANITIZE="${SANITIZE} -fsanitize=null"
SANITIZE="${SANITIZE} -fsanitize=signed-integer-overflow"
SANITIZE="${SANITIZE} -fsanitize=bounds"
#SANITIZE="${SANITIZE} -fsanitize=bounds-strict"
SANITIZE="${SANITIZE} -fsanitize=bool"
SANITIZE="${SANITIZE} -fsanitize=enum"
#SANITIZE="${SANITIZE} -fsanitize-recover" # will try to continue running the program
#SANITIZE_LINK="-static-libasan -static -lasan -static -lubsan -ldl -lm"
SANITIZE_LINK="-l:libasan.a -l:libubsan.a -ldl -lm"
SANITIZE="${SANITIZE} -fno-sanitize=alignment"
./autogen.sh
./configure
make clean
make CFLAGS="${SANITIZE} -g -O2" LDFLAGS="${SANITIZE_LINK}"
make CC=gcc CFLAGS="${SANITIZE} -g -O2" LDFLAGS="${SANITIZE_LINK}" test

- name: Build and Test (Normal)
env:
SKIP: python2
run: |
./autogen.sh
./configure
make clean
make
make test

- name: Provide log as artifact
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: shc.failingtests
path: |
/tmp/shc.*.tst/*
retention-days: 2
41 changes: 41 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Generate files (documentation, autotools)
on:
push:
paths: [man.md, aclocal.m4, configure.ac]
workflow_dispatch:
jobs:
convert_via_pandoc:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
man:
- 'man.md'
autotools:
- 'aclocal.m4'
- 'configure.ac'
- uses: docker://pandoc/core:3.3
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' }}
with:
args: -s man.md -t man -o shc.1
- uses: docker://pandoc/core:3.3
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' }}
with:
args: -s man.md -t html -o man.html
- run: |-
./autogen.sh
# Correct executable flag on generated files
chmod -x INSTALL
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.autotools == 'true' }}
- name: Commit changes
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' || steps.changes.outputs.autotools }}
run: |-
for r in $(git remote) ; do git remote get-url --all $r ; done
git config user.name github-actions
git config user.email [email protected]
git commit -a -m "ci: Github Action Generate Files"
git push
51 changes: 51 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: pre-commit
on:
pull_request:
push:
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
RAW_LOG: pre-commit.log
CS_XML: pre-commit.xml
steps:
- run: sudo apt-get update && sudo apt-get install cppcheck
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
python-version: "3.12.1"
- run: python -m pip install pre-commit
- uses: actions/cache/restore@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
}}
- name: Run pre-commit hooks
env:
SKIP: uncrustify
run: |
set -o pipefail
pre-commit gc
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG}
- name: Convert Raw Log to Annotations
uses: mdeweerd/[email protected]
if: ${{ failure() }}
with:
in: ${{ env.RAW_LOG }}
- uses: actions/cache/save@v4
if: ${{ ! cancelled() }}
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
}}
- name: Provide log as artifact
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: precommit-logs
path: |
${{ env.RAW_LOG }}
${{ env.CS_XML }}
retention-days: 2
101 changes: 101 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
exclude:
(?x)^(
configure|
configure\..*|
.cache/.*|
.*Makefile.in|
.*Makefile.am|
autogen.sh|
config/install-sh|
config/depcomp|
config/compile|
config/missing|
aclocal.m4|
__NONE__)$
repos:
- repo: https://github.com/executablebooks/mdformat
# Do this before other tools "fixing" the line endings
rev: 0.7.17
hooks:
- id: mdformat
name: Format Markdown
stages: [manual]
entry: mdformat # Executable to run, with fixed options
language: python
types: [markdown]
args: [--wrap, '75', --number]
additional_dependencies:
- mdformat-toc
- mdformat-gfm
- mdformat-beautysh
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# - id: no-commit-to-branch
# args: [--branch, main]
- id: debug-statements
- id: end-of-file-fixer
exclude: ^(test/.*)$
- id: trailing-whitespace
exclude: .*\.md$
- id: check-json
- id: mixed-line-ending
- id: check-builtin-literals
args: [--ignore=dict]
- id: check-ast
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
exclude: ^(test/.*)$
- id: check-docstring-first
- id: fix-byte-order-marker
- id: check-case-conflict
- id: check-toml
- repo: https://github.com/lovesegfault/beautysh.git
rev: v6.2.1
hooks:
- id: beautysh
exclude: (?x)^(test/test\..*|config/missing|configure|autogen.sh)$
additional_dependencies:
- setuptools
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args:
- --toml
- pyproject.toml
additional_dependencies:
- tomli
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
# Install dependencies on windows:
# choco install llvm uncrustify cppcheck
hooks:
- id: uncrustify
args: [--replace, --no-backup, -c, uncrustify.cfg]
- id: cppcheck
args:
- --force
#- --std=c99
- --language=c
#- -IInc
- '--template={file}({line}): {severity} ({id}): {message}'
- --inline-suppr
- id: cpplint
args: ["--filter=-build/header_guard,-build/include,-build/include_subdir,-legal/copyright,-readability/casting,-readability/fn_size,-whitespace/blank_line,-whitespace/braces,-whitespace/comma,-whitespace/comments,-whitespace/line_length,-whitespace/newline,-whitespace/operators,-whitespace/parens,-whitespace/semicolon,-whitespace/tab,-whitespace/todo"]
additional_dependencies:
- cpplint>=1.6.1
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
exclude: (?x)^(test/test.*)$
# args: [-x,-e1007,-e1009,-e1072,-e1073]
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
stages: [manual]
args: [-i]
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ sudo: required
language: c
before_install:
- sudo apt-get update -q
- sudo apt install dash bash ash ksh zsh tcsh csh rc
script:
- sudo apt install dash bash ksh zsh tcsh csh rc
script:
- ./autogen.sh
- ./configure
- make
- make test


48 changes: 34 additions & 14 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
CHANGES

LATEST Aug 19 2024

* Feat: Piping (`-P`, `-p`), with `$0` forging (big scripts, perl. python) @fabio-brugnara.
* Qual: Enhance tests (Check stderr, forging, tempdir, complex arguments), option SKIP (tests) @mdeweerd.
* Qual: Add Github CI flox (build, run tests with(out) sanitizer, generate files) @mdeweerd.
* Fix: Fix memory leaks in generated c-code @mdeweerd.
* Fix: Fix memory leaks in generation c-code @ashamedbit #165
* Fix: Fix static code checks/implement recommendations (prevent leaks, overflows) @mdeweerd.
* Qual: Add static code checks, linting, code formatting @mdeweerd #162 #161
* Doc: Improvements to the documentation @mdeweerd #163 #160
* Doc: Add code block hinting for Ubuntu PPA install procedure lb803 #164
* Feat: Remove `ash` dependency @dviererbe #167
* Fix: Fix for script filenames with spaces/special characters @ergoucao #157.
* Feat: Option `-2` to use mmap2 @csersoft #132
* Doc: Fix automatic hyperlinks by removing `<>` @learnpassword #148
* Doc: Fix typo in usage @ghost #129
* Fix: Fix strip in case of cross-compilation @embexus #125
* Fix: Fix NULL-ptr dereference in shhl string @RKX1209 #83

Note: @GITHUB_USERNAME #neurobin/Github Pull Request

4.0.3 Tue Nov 20 08:22:20 UTC 2018

* Enhance -H flag by intika <https://github.com/intika> (Hide commands arguments from ps and cmdline)
Expand Down Expand Up @@ -44,29 +65,29 @@ CHANGES

* zsh support
* Fix issue #13 (https://github.com/neurobin/shc/issues/13)


3.9.2 Fri Aug 21 16:12:33 BDT 2015

Added BusyBox support with patch taken from:
https://onedrive.live.com/prev?cid=18a41d08a9f3c543&id=18A41D08A9F3C543!231&authkey=!AJQ6Iah_5D3WJ60&v=TextFileEditor
as suggested by https://github.com/marcoburatto

3.9.1 Fri Apr 03 00:22:11 GMT 2015

Renamed option -T to -U and reversed it's logic.
So now, the executable prepared will execute without using sudo,
by default.


3.9.0 Wed Apr 01 08:35:22 AM GMT 2015
3.9.0 Wed Apr 01 08:35:22 AM GMT 2015

(http://github.com/neurobin)
Added output file option with [-o filename]
and fixed bug on make install (manual install failed)
Now you can access manual by entering command: man shc
in a terminal.



3.8.9 Wed Apr 25 09:24:25 CEST 2012
Expand Down Expand Up @@ -122,8 +143,8 @@ CHANGES
- Fixed bug: "rlax" used after encryption.

Thanks to Nalneesh Gaur <[email protected]> for:
- Read permision of the script.x exposes it to disassembling.
- Group and others read permision is now removed by default.
- Read permission of the script.x exposes it to disassembling.
- Group and others read permission is now removed by default.



Expand Down Expand Up @@ -227,16 +248,15 @@ SCO, both not used now.
3.0b1 Wed Feb 26 14:27:22 WET 1997

The main difference with 2.4 is that in it the script was
compressed an then shuffle around, now int 3.0 the script is encripted
with an inline code, so not needend any external comand to work, and been
faster at startup. Other related adventage is that the only information
not encripted in .x.c is an stamp, expiration date and provider email
compressed an then shuffle around, now int 3.0 the script is encrypted
with an inline code, so not needing any external command to work, and been
faster at startup. Other related advantage is that the only information
not encrypted in .x.c is an stamp, expiration date and provider email
address.

Something equivalent to cheksums have been used to enforced at
Something equivalent to checksums has been used to enforce at
execution that the executing shell has not been modified from the time
the script was compiled. If anybody tries to change the excuting shell,
the script was compiled. If anybody tries to change the executing shell,
.x will refuse to execute.

The generated .x.c source code is now readable.

6 changes: 3 additions & 3 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Installation Instructions
*************************

Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
Foundation, Inc.
Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free
Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
Expand Down Expand Up @@ -225,7 +225,7 @@ order to use an ANSI C compiler:

and if that doesn't work, install pre-built binaries of GCC for HP-UX.

HP-UX 'make' updates targets which have the same time stamps as their
HP-UX 'make' updates targets which have the same timestamps as their
prerequisites, which makes it generally unusable when shipped generated
files such as 'configure' are involved. Use GNU 'make' instead.

Expand Down
Loading