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

Added optional parameter for deployment script #570

Closed
wants to merge 12 commits into from

Conversation

ashish493
Copy link

Fixes for the issue #552
Added the optional parameter for the linux deployment scripts and modified the Url's in the config file for the latest relese without using GH API's.

I will be modifying the windows deployment script soon, but it's config file need a lot of changes which will take some time.

if exists wget; then
wget -c -N -P "${MONKEY_BIN_DIR}" ${SAMBACRY_64_BINARY_URL}
wget -c -N -P "${MONKEY_BIN_DIR}" ${SAMBACRY_32_BINARY_URL}
read -p "Do you want to use the latest binaries, Press Y, otherwise specify the version to downloaded " Resp
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a command line parameter, not interactive.

@danielguardicore
Copy link
Contributor

Code looks decent. It's important to note usability wise, this should be a command line parameter and not intereactive.

Comment on lines 244 to 246
tlink_64='https://github.com/guardicore/monkey/releases/download/'
tlink_64+=$Resp
tlink_64+='/traceroute64'
Copy link
Contributor

Choose a reason for hiding this comment

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

You can do this in a cleaner way using
tlink_64="https://github.com/guardicore/monkey/releases/download/$resp/traceroute64"

Do the same for all the other things?

Copy link
Author

Choose a reason for hiding this comment

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

Ok then, I will rectify it..
and the command line parameter..

@ashish493
Copy link
Author

ashish493 commented Mar 14, 2020

@danielguardicore Can you review now?
I have also updated for windows deployment scripts..

wget -c -N -P "${MONKEY_BIN_DIR}" ${SAMBACRY_64_BINARY_URL}
wget -c -N -P "${MONKEY_BIN_DIR}" ${SAMBACRY_32_BINARY_URL}

if [ $# = 0 ] ; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not explicitly check what the argument is?

curl -o ${MONKEY_BIN_DIR}/sc_monkey_runner64.so ${SAMBACRY_64_BINARY_URL}
curl -o ${MONKEY_BIN_DIR}/sc_monkey_runner32.so ${SAMBACRY_32_BINARY_URL}
log_message "Downloading sambacry binaries"
slink_64="https://github.com/guardicore/monkey/releases/download/$1/sc_monkey_runner64.so"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you downloading using the first argument and not a variable?

@danielguardicore
Copy link
Contributor

danielguardicore commented Mar 15, 2020

@ashish493 could you better explain what the command line interface is now, for both powershell and bash?
Also in PS, avoid using positional arguments. There is no reason it can't be a named parameter with a default value. This will simplify your code

@ashish493
Copy link
Author

ashish493 commented Mar 15, 2020

At present,
in Linux Script, We just run the bash script, If a user doesn't provide any arguments ( which is the default case), our script will download the Latest release of binaries,
and if the developer wants, to use/work on a specific version of binaries, then he/she might provide the arguments in the version format, as specified in the docs( Which I will update in docs), the script will download that particular version of binary release.

Same logic goes for the powershell Script, If no arguments, download latest,
else if any version (or argument is specified), it will download that...

In both the cases, I'm using only the first argument (as a temporary solution) for downloading, I'm still finding for a way around it, as it may cause some security concerns..
@danielguardicore , are there any suggestions?

@danielguardicore
Copy link
Contributor

Can you add to the PR the updated docs?

@ashish493
Copy link
Author

ashish493 commented Mar 19, 2020

@danielguardicore Can u review now?

@codecov
Copy link

codecov bot commented Mar 19, 2020

Codecov Report

❗ No coverage uploaded for pull request base (develop@280946a). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop     #570   +/-   ##
==========================================
  Coverage           ?   56.15%           
==========================================
  Files              ?      105           
  Lines              ?     3588           
  Branches           ?        0           
==========================================
  Hits               ?     2015           
  Misses             ?     1573           
  Partials           ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 280946a...fcdfeae. Read the comment docs.

- `./deploy_linux.sh "" "" "v1.7.1" ` (If you want to download any specific version of the releases, Provide the version in the 3rd argument, Else by Default, it will download the latest release of binaries)
Copy link
Contributor

Choose a reason for hiding this comment

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

lowercase p, e and D, or change the grammer.

Copy link
Author

Choose a reason for hiding this comment

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

Sure 👍.

@@ -8,6 +8,9 @@ param(
[Parameter(Mandatory = $false, Position = 2)]
[Bool]
$agents = $true
[Parameter(Mandatory = $false, Position = 3)]
[System.String]
$version = "v1.7.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 1.7? Why are we not querying for latest release?

Copy link
Author

@ashish493 ashish493 Mar 27, 2020

Choose a reason for hiding this comment

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

I made the changes in the config file to fetch the latest, although "v1.7.0" isn't a parameter, I have just set it to define the argument type. And when we specifically provide the version argument, it will then only download that particular version. Otherwise it's going to download the latest.

@acepace acepace closed this Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants