Git Product home page Git Product logo

Comments (2)

sonofagl1tch avatar sonofagl1tch commented on June 21, 2024 1

looking at this bash i was using a full string match as my conditional which worked before the aws template updates. looks like now we need more of an "if a string contains substring" type of conditional. similar to the code snippet below.

string='My long string'
if [[ $string == *"My long"* ]]; then
  echo "It's there!"
fi

https://stackoverflow.com/questions/229551/how-to-check-if-a-string-contains-a-substring-in-bash

from awsdetonationlab.

mgmacias95 avatar mgmacias95 commented on June 21, 2024

Hello @sonofagl1tch,

After updating AMIs used in the CF template in 3f4cbfd, the template was still failing:
imagen

I disabled rolling back when the template failed so I was able to do some checks in the environment and get further information about the error. I accessed bastion machine and found out the bastion_bootstrap.sh script is failing:

# /tmp/bastion_bootstrap.sh --banner https://raw.githubusercontent.com/sonofagl1tch/AWSDetonationLab/master/artifacts/banner_message.txt --enable true --tcp-forwarding true --x11-forwarding false
checkos Ended
BANNER_PATH = https://raw.githubusercontent.com/sonofagl1tch/AWSDetonationLab/master/artifacts/banner_message.txt
Creating Banner in /etc/ssh_banner
curl  -s https://raw.githubusercontent.com/sonofagl1tch/AWSDetonationLab/master/artifacts/banner_message.txt > /etc/ssh_banner
[INFO] Installing banner ...
Setting up bastion session log in /var/log/bastion/bastion.log
ln: failed to create hard link ‘/var/log/bastion/.bastion.log’: File exists
Value of TCP_FORWARDING - true
Value of X11_FORWARDING - false
[ERROR] Unsupported Linux Bastion OS

Searching in the script's code, I found out where the error was being raised:

release=$(osrelease)
# Ubuntu Linux
if [ "$release" == "Ubuntu" ]; then
#Call function for Ubuntu
ubuntu_os
# AMZN Linux
elif [ "$release" == "AMZN" ]; then
#Call function for AMZN
amazon_os
# CentOS Linux
elif [ "$release" == "CentOS" ]; then
#Call function for CentOS
cent_os
else
echo "[ERROR] Unsupported Linux Bastion OS"
exit 1
fi

It seems the result from osrelease function isn't correct. Reviewing that function:
function osrelease () {
OS=`cat /etc/os-release | grep '^NAME=' | tr -d \" | sed 's/\n//g' | sed 's/NAME=//g'`
if [ "$OS" == "Ubuntu" ]; then
echo "Ubuntu"
elif [ "$OS" == "Amazon Linux" ]; then
echo "AMZN"
elif [ "$OS" == "CentOS Linux" ]; then
echo "CentOS"
else
echo "Operating System Not Found"
fi
echo "${FUNCNAME[0]} Ended" >> /var/log/cfn-init.log
}

It seems the following command is returning a wrong value:

# cat /etc/os-release | grep '^NAME=' |  tr -d \" | sed 's/\n//g' | sed 's/NAME=//g'
Amazon Linux AMI

But I don't know if replacing content in line 61 would be a good fix, since it was changed here:
awslabs/amazon-guardduty-tester@9fb76df#diff-18583a0977c9ce589518e28d2ef9a78c
Am I using an old instance by error when I changed AMIs?

Best regards,
Marta

from awsdetonationlab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.