Making an attempt to concatenate a string with a variable containing a number of values
This error happens when attempting to concatenate a string and a tuple. What’s a tuple? It’s mainly a number of values in a variable as an alternative of a single string worth.
If you would like a extra technical definition:
Methods to repair?
Effectively one factor you possibly can strive is to only convert each values to a string to attempt to see the place the issue lies:
print (str(val1) + str(val2))
You’ll be able to check to see in case your worth is a tuple:
kind(val1) is tuple
Or a string:
kind(val2) is str
Elevate an error if one thing isn’t the right kind earlier than you course of the info:
if (kind(val2) is just not str:
increase Exception("val2 have to be a string")
Test the worth exists earlier than printing it:
if val2 is None:
increase Exception("val2 should not be None")if (kind(val2) is just not str:
increase Exception("val2 is just not a string: " + str(val2))
Watch out when printing out strings in error messages as it is a level the place an attacker may attempt to inject code that may get processed incorrectly or power an error to attempt to print out delicate knowledge. These are issues I check for on penetration exams.
Teri Radichel
For those who appreciated this story please clap and comply with:
Medium: Teri Radichel or E mail Checklist: Teri Radichel
Twitter: @teriradichel or @2ndSightLab
Requests providers by way of LinkedIn: Teri Radichel or IANS Analysis
© 2nd Sight Lab 2022
____________________________________________
Writer:
Cybersecurity for Executives within the Age of Cloud on Amazon
Want Cloud Safety Coaching? 2nd Sight Lab Cloud Safety Coaching
Is your cloud safe? Rent 2nd Sight Lab for a penetration check or safety evaluation.
Have a Cybersecurity or Cloud Safety Query? Ask Teri Radichel by scheduling a name with IANS Analysis.
Cybersecurity & Cloud Safety Assets by Teri Radichel: Cybersecurity and Cloud safety lessons, articles, white papers, shows, and podcasts