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

WIP: Merge 1.8 changeset #15

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft

WIP: Merge 1.8 changeset #15

wants to merge 11 commits into from

Conversation

AfroThundr3007730
Copy link
Owner

@AfroThundr3007730 AfroThundr3007730 commented Mar 11, 2024

(update from commits when ready)

Add fixes: and see: tags

Review this before merging. Particularly, add utils.common.sh as a module and factor out vendored utility functions.

TODO: Need to figure out which changes in this should be split into another release. The total refactor is already cumbersome without the functionality changes.

syncrepo.sh Outdated Show resolved Hide resolved
syncrepo.sh Outdated
"$name" "$@"
utils.say -d 'leaving %s' "$name"
utils.say -d '%-*s leave %s' $((--call_count)) '<-' "$name"
}

# Log message and print to stdout
# shellcheck disable=SC2059
utils.say() {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Modifiy this to write to stderr, where apropriate (and adjust tee accordingly).

syncrepo.sh Outdated
@@ -656,7 +661,7 @@ syncrepo.sync_downstream() {
local repo package_list
utils.say 'Configured as downstream, so mirroring local upstream.'

[[ -n $SR_MIRROR_UPSTREAM ]] || {
[[ $SR_MIRROR_UPSTREAM ]] || {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Rework upstream/downstream variables and how they're set.

@AfroThundr3007730 AfroThundr3007730 self-assigned this Mar 11, 2024
@AfroThundr3007730 AfroThundr3007730 added the -core Component: syncrepo script label Mar 11, 2024
@AfroThundr3007730 AfroThundr3007730 marked this pull request as draft March 11, 2024 16:39
@AfroThundr3007730 AfroThundr3007730 linked an issue Mar 11, 2024 that may be closed by this pull request
@AfroThundr3007730 AfroThundr3007730 added the enhancement Enhancing existing capabilities label Mar 13, 2024
syncrepo.sh Outdated
}

# And a few more (ClamAV)
[[ $CLAMAV_SYNC == true ]] &&
clamsync="clamavmirror -a $CMIRROR -d $CLAMREPO -u root -g www-data"
[[ $SR_SYNC_CLAMAV == true ]] && {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Investigate replacing clamavmirror with cvdupdate, or writing our own, if necessary.

set -euo pipefail
shopt -s extdebug

# TODO: Implement support for Rocky (and maybe Alma)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

shopt -s extdebug

# TODO: Implement support for Rocky (and maybe Alma)
# TODO: Implement support for RHEL based SecurityOnion
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found


# TODO: Implement support for Rocky (and maybe Alma)
# TODO: Implement support for RHEL based SecurityOnion
# TODO: Implement Docker registry sync logic (also podman registry)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

# TODO: Implement support for Rocky (and maybe Alma)
# TODO: Implement support for RHEL based SecurityOnion
# TODO: Implement Docker registry sync logic (also podman registry)
# TODO: Fix upstream/downstream logic and detection (also variables)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

QUIET=true
shift
elif [[ $1 == -v ]]; then
# TODO: Implement verbose or remove this
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

fi
fi
# TODO: Test the tput combinations on multiple distros
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

exit 1
}

# TODO: Dig through the other functions and move their checks here
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found


# Sync docker repository (for each enabled OS)
# TODO: Use wget_rsync() instead of a regular clone
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

say 'Beginning sync of ClamAV repository from %s.' "$CMIRROR"
$clamsync &>> $PROGFILE
say 'Done.\n'
# TODO: Replace with wget_rsync()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

else
# Do a downstream sync
UMIRROR=${UMIRROR:=$MIRROR} && ds_sync
# TODO: This should probably be empty until set by the user
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO found

Copy link

codeclimate bot commented Mar 19, 2024

Code Climate has analyzed commit cb60c03 and detected 10 issues on this pull request.

Here's the issue category breakdown:

Category Count
Bug Risk 10

View more on Code Climate.

src/syncrepo.sh Dismissed Show dismissed Hide dismissed
src/syncrepo.sh Dismissed Show dismissed Hide dismissed
src/syncrepo.sh Fixed Show fixed Hide fixed
src/syncrepo.sh Fixed Show fixed Hide fixed
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Signed-off-by: Eddie Carswell <eddiecarswell13@yahoo.com>
- Fix variable quoting and expansion issues
- Converted globals to be overrideable
- Formatted code for increased legibility
- Fixed nonstandard exit code usage

Signed-off-by: Eddie Carswell <eddiecarswell13@yahoo.com>
- Sync components implicitly inherit from SR_SYNC_ALL_REPOS
- All SR_SYNC_* variables default to off and may be overridden
- Made owner UID:GID of repository files configurable
- Added ability to load configuration from the files:
    `/etc/syncrepo.conf` and `/etc/syncrepo/syncrepo.conf`
  The most specific path overrides the former, when settings conflict,
  otherwise they merge. Expected format is an environment file.
- Adjusted a couple function names to not be truncated
- Renamed remaining variables for descriptiveness and namespacing
- Marked all local variables as local
- Added rudimentary config generation logic
- Cleaned up utility functions
- Adjusted help text and CLI interface (WIP)

Signed-off-by: Eddie Carswell <eddiecarswell13@yahoo.com>
Converted any variable that was better off as an array into one

Signed-off-by: Eddie Carswell <eddiecarswell13@yahoo.com>
Signed-off-by: Eddie Carswell <eddiecarswell13@yahoo.com>
Signed-off-by: Eddie Carswell <eddiecarswell13@yahoo.com>
- Enabled bash "strict mode" to catch more issues
- Fixed all uses of uninitialized variables (so far)
- Adjust utility functions argument handling
- Improved debug call stack tracing

Signed-off-by: Eddie Carswell <eddiecarswell13@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-core Component: syncrepo script enhancement Enhancing existing capabilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use a config file instead of hardcoding options
1 participant