Exclusive

The son of ex-"Real Housewives of Orange County" star Lauri Peterson is off the hook for attempted murder -- thanks to a sweet plea deal -- and he's walking out of jail.

Josh Waring pled guilty on Friday to felony counts of assault with a firearm, evading a peace officer, 2 counts of assault, hit-and-run with property damage and battery ... this according to court records. Waring's attorney, Joel Garson, tells us Waring will get time served and be released later today.

As we've reported ... Waring's been locked up for nearly 4 years while waiting for his trial since his July 2016 arrest when he was accused of shooting a man outside a sober living home. He initially pled not guilty.

It's been a harrowing time for Waring behind bars. As we first reported ... he was ambushed back in October 2019 at the Orange County jail in Santa Ana and brutally assaulted by another inmate wielding razors wrapped in towels.

Play video content TMZ.com

Waring suffered deep gashes to his chest and face. Waring's lawyer believed the attack could have been retaliation against Josh for filing a federal lawsuit against Orange County and its Sheriff's Department for violating his civil rights.