The Bernard Madoff scandal is not only another blow to trust and confidence on Wall Street, but another knock on the reputation of the Securities and Exchange Commission — supposedly the cop on the financial-markets beat.

Earlier this year, SEC Chairman Christopher Cox famously said Bear Stearns was in reasonably good shape three days before the firm went belly-up.

Now Cox has blasted his career regulators for failing to unearth the alleged $50 billion Ponzi scheme that Madoff is accused of running with his investment firm, Bernard L. Madoff Investment Securities LLC.

Remarkably, the Madoff operation had been subjected to several SEC inquiries over the years, most recently in 2007.

But Cox, in a blistering rebuke of his own staffers, says they never sought a formal commission-endorsed investigation, which — given the SEC’s power of subpoena — would have forced Madoff to produce critical information about his operation.

Officials say Madoff kept more than one set of books.

Another wrinkle emerged in a Wall Street Journal report that former SEC lawyer Eric Swanson married Madoff’s niece, Shana, in 2007. Swanson, according to an SEC statement, was a member of the agency’s team that examined Madoff’s brokerage twice.

The revelation prompted the SEC’s inspector general’s office to say it planned an examination of the relationship.

The signs of rot in Madoff’s brokerage operation seem obvious in retrospect, especially the steadily increasing returns he posted in bad years as well as good ones. In addition, the auditing firm engaged to keep the books was unusually small for a business with billions under investment.

Madoff’s client list included many prominent wealthy figures such as Jeffrey Katzenberg, chief executive of DreamWorks Animation, along with charities, Swiss banks, billionaires and affluent retirees. Several charities and at least two foundations have been forced to close because of losses.

Investigators are still trying to piece together exactly how Madoff ran his alleged scam.

Obviously something is amiss with the SEC, which is now a ripe subject for a congressional inquiry with a view toward strengthening the agency. If Madoff’s operation had been uncovered earlier, a great deal of heartache and financial loss could have been avoided.