I'm talking thematically Section 31 doesn't fit within Star Trek outside of the morally ambiguous setting of DS9. It's made pretty clear that Section 31 is a rogue organisation that does what it wants without the consent or approval of Starfleet. Small numbers of rogue officers like in "The Undiscovered Country", "The Pegasus" and "Paradise Lost" do not represent Starfleet. The only time Starfleet does morally questionable things is in the event of war "In the Pale Moonlight", or when they're engaged in hostilities with another race "The Enterprise Incident". Also the Klingons having the Narada for 25 years isn't canon because it's from a deleted scene.
The Undiscovered Country: Assassination of a Klingon pacifist, attempted assassination of the President of the Federation, to cause galactic scale war between the Klingons and the Federation. Orchestrated by Admiral Cartwright, Colonel West of Starfleet, and General Chang and Ambassador Nanclus of the Klingon and Romulan empires. While Chang was down for a war. Let's not forget it was 2 Starfleet personell who killed Gorkon and several Klingons, Lt. Valeris who collaborated and set Kirk up to take the fall for the crime, and Colonel West himself who was going to shoot the President of the Fed. The roundtable scene makes it clear not all StarFleet Command is comfortable with peace with the Klingons. Kirk himself was ready to let them all die and he probably wouldn't have objected to a war with them. We can assume Cartwright had other supporters in the Admiralty and among the Captains but it was his operation he undertook.
TNG Pegasus: The development of a phasing cloak was an illegal experiment carried out by a then Captain Pressman. The experiment went awry and the crew, experiment, and ship were lost. Years later Picard found out there was a token inquiry in to the loss of the Pegasus but was never truly investigated. The fact that Pressman was a captain at the time and later promoted to Admiral means the phasing cloak experiment was handed down to him from a higher authority than he had at the time as a captain. When exposed and facing court martial, he tells Picard he has a lot of friends at StarFleet Command. He likely faced no repercussions or dishonorable discharge for his conduct.
DS9 Paradise Lost and Homefront: was a Coup d'état by Admiral Leyton to turn Earth in to a police state to protect against the extreme infiltration threat the Dominion posed. While Leyton's plot was foiled and he did resign. We do know this is when Odo was infected with the morphogenic virus. Odo was on Starfleet property the entire time and only interacted with Starfleet scientist in developing ways to detect changelings. I'm sure someone at the admiralty OKed the use of the virus to Section 31, and Odo was infected. They were considerate enough to ensure Odo himself would not develop the symptoms but unforseen events by Starfleet caused him to.
TNG Insurrection: We have Admiral Doughtery working with Dominion allies to relocate 600 people off a planet with mutagenic healing properties. Through use of duck blind missions, a federation holodeck ship with a cloaking device (cloaking tech is still a violation right), and agreeing with Ru'afo to send ships to "stop" the Enterprise. Doughtery was willing to destroy the flagship and his crew for the particles. His plan failed when the knowledge that the Son'a and Ba'ku were the same race surfaced. Explaining that to Starfleet Command; who knew every detail about this mission expect that one would be a hard one to defend to other Federation planets and new entries to the Fed. Not something you want in the Federation Brochure about your wonderful utopian society.
DS9 In the Pale Moonlight : Ends justify the means scenario that we never see the repercussions of. Sisko weighs the options and decides that involving the Romulans in the Dominion War is the only way to preserve the Federation. He has Garak forge a false holodeck simulation and assassinate a Romulan delegate. Sisko at the end of his log says he can live with the decision. However we never learn Romulus' body count for their involvement, and Sisko "dies" soon after the conclusion of the war. So we never see him wrestle with his conscience or reflect on his decision. I doubt he would've remained as "Defiant" as he was 'In The Pale Moonlight' some time after 'What You Leave Behind'.
DS9 Inter Arma Enim Silent Leges: Secures in stone that StarFleet Command is not just playing footsie with Section 31, they are sharing a bed with them. Admiral Ross reciting the latin phrase at Bashir to justify his and Sloan's actions sums up that anything goes as long as it's to protect the Federation. Sisko, Doughtery, Leyton, Sloan, Pressman and Valeris all uttered the same sentiment when confronted with their actions. It doesn't make them wrong, it just makes them as dirty as other empires we see in the Trekverse.
I could continue but I think I've made my point. Starfleet Command and Admirals are bent. Hell look at my icon Janeway. All the shady things she did in the Delta Quadrant and she's promoted to Vice Admiral less than a year after Voyager got back to Earth. It's like you have to bend the rules in order to get promoted to the Admiral Nechayev or Admiral Satie level of dickery. Also a special shout out to Admiral Jameson for his bent use of the Prime Directive to insight a 40 year civil war.