Idiom to mean "one must avoid going into dangerous situations"
In my native language, there's an idiom that someone warn you not to go into a dangerous situation when you're sure you'll get into trouble but you still feel like doing it. For instance, making jokes about your boss at work because he/she has shamed you in public. One of your co-workers might say:
Don't play with lion's tail!
Is there an English idiom for such a situation?
I have an idiom and a proverb (saying) for you!
to play with fire
- to do something that could cause you great trouble later
- Example: "Don't you know you're playing with fire when you get involved with someone who's already married?"
Source: Cambridge Dictionary of American Idioms (via thefreedictionary.com)
There is a common saying using the same imagery:
If you play with fire, you get burned.
- If you do something dangerous, you will get hurt.
- Example: Joe said, "I have no sympathy for race-car drivers who get injured. They should know that if you play with fire, you get burned."
- Example: My mother always told us that experimenting with hard drugs was playing with fire.
Source: McGraw-Hill Dictionary of American Idioms and Phrasal Verbs (via thefreedictionary.com)
Idioms such as "to dance with death" and phrases like "there will be hell to pay" (or "there will be the devil to pay") are a bit too dramatic in this context.
I'm sure there is more, but I'll let others do some work as well.
The phrase I immediately thought of is: Fools rush in where angels fear to tread.
It means: "The rash or inexperienced will attempt things that wiser people are more cautious of".
The Phrase Finder article states:
'Fools rush in...' has a precise derivation, in that it is a quotation from the English poet Alexander Pope's An essay on criticism, 1709. (Lines from the poem follow in this entry.)
It is pretty widely known, including being used in a speech by Abraham Lincoln and in the song Fools Rush In (Where Angels Fear to Tread), a 1940 song sung by Frank Sinatra.
As other answers indicate, there many idiomatic expressions used to warn someone against doing something potentially dangerous. But in OP's specific case - warning a co-worker not to be flippant/disrepectful to the boss at work - I'd go for...
"Don't beard the lion in his den" (OED beard - v. oppose openly, with daring or with effrontery).
People who play with matches get burnt.