Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company 👇
Go aicertificationcloud-engineeringcybercybersecuritycybersecurity-analystcybersecurity-certificationcybersecurity-certificationscybersecurity-educationcybersecurity-jobscybersecurity-portfoliocybersecurity-projectscybersecurity-toolsgrchackinglearningpentestingproject-repositoryprojetcspython
feat(khaos): the UNSUPPORTED verdict, measured rather than declared
CarterPerez-dev2bd743b17201
diff --git a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/catalog.go b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/catalog.goindex 136c6f31..aa96773c 100644--- a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/catalog.go+++ b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/catalog.go@@ -81,6 +81,10 @@ type Shape struct {Consulted func() int64ConsultedWhat string+ // Unsupportable names the check whose absence is itself the finding, which+ // turns a never-consulted endpoint into UNSUPPORTED rather than a void run.+ Unsupportable string+// IdleFor asks the engine for the idleness discriminator.IdleFor time.Duration@@ -251,6 +255,7 @@ func Build(HeldCaveat: shape.HeldCaveat,Consulted: shape.Consulted,ConsultedWhat: shape.ConsultedWhat,+ Unsupportable: shape.Unsupportable,IdleFor: shape.IdleFor,Act: shape.Act,ActDetail: shape.ActDetail,diff --git a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/engine.go b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/engine.goindex 4c0980f5..349fa628 100644--- a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/engine.go+++ b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/engine.go@@ -125,6 +125,7 @@ func (e Engine) measureBaseline()observation.ConsultedWhat = spec.ConsultedWhat+ observation.Unsupportable = spec.Unsupportableobservation.Consulted = e.consulted(spec) - consultedBeforereturn observationdiff --git a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/experiment.go b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/experiment.goindex cb903426..1b6d29fa 100644--- a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/experiment.go+++ b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/experiment.go@@ -159,6 +159,22 @@ type Experiment struct {Consulted func() int64ConsultedWhat string+ // Unsupportable names the check whose ABSENCE is a finding in its own+ // right, and turns a never-consulted endpoint into UNSUPPORTED instead of+ // BASELINE-NOT-MET.+ //+ // The two readings of "the target never touched the endpoint" are opposite+ // and both are sometimes right. For the introspection experiments it means+ // khaos faulted something the target does not use, so the run is void and+ // baseline-not-met is honest. For the revocation experiments it is THE+ // ANSWER: no mainstream TLS stack checks revocation by default, Go's does+ // not check it at all, and a target that never asked has no revocation+ // check that could have failed.+ //+ // Only an experiment that declares this gets the second reading, because+ // nothing in a request count distinguishes the two situations.+ Unsupportable string+// IdleFor turns on the idleness discriminator. It must be longer than the// target's own decision-cache lifetime, which khaos cannot discover, so the// experiment declares it as a parameter and the verdict names the pause itdiff --git a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/unsupported_test.go b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/unsupported_test.gonew file mode 100644index 00000000..d53c661f--- /dev/null+++ b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/unsupported_test.go@@ -0,0 +1,132 @@+// ©AngelaMos | 2026+// unsupported_test.go++package experiment++import (+ "testing"++ "github.com/CarterPerez-dev/khaos/internal/probe"+)++// The UNSUPPORTED verdict, which M7's exit gate turns on.+//+// Go's crypto/x509 performs no revocation checking of any kind and has no+// option to turn it on, so a Go target handed a certificate revoked in a valid,+// in-date, correctly signed CRL from its own issuer accepts it with a nil+// error. Three readings of that are available and two of them are lies:+//+// - PASSED is the worst. The certificate really was revoked and really was+// used, and khaos would be reporting a clean survival.+// - PERMITTED accuses the target of skipping a check it never had.+// - UNSUPPORTED says what happened: there was no revocation check to fail,+// so khaos makes no security claim.+//+// The distinction is MEASURED. khaos counts what the target fetched from the+// authority, so a target that never asked is an observation, and a target that+// asked and used the certificate anyway is still the defect it is.++// revocationObservation is a run where the fault landed, the baseline was+// healthy, and the target accepted the revoked credential throughout. Only+// `consulted` varies, which is the whole point: everything else about these two+// runs is identical and the verdict has to differ.+func revocationObservation(consulted int64) Observation {+ return Observation{+ FaultConfirmed: true,+ Baseline: healthyBaseline(),+ Fault: probe.Window{+ Valid: stream(+ probe.Valid,+ repeat(probe.Accepted, MinimumPaired)...),+ Invalid: stream(+ probe.Invalid,+ repeat(probe.Rejected, MinimumPaired)...),+ },+ Recovery: healthyRecovery(),++ Unsupportable: "revocation checking",+ ConsultedWhat: "khaos's CRL distribution point",+ Consulted: consulted,+ }+}++func TestATargetThatNeverCheckedRevocationIsUnsupportedNotPassed(t *testing.T) {+ verdict := Judge(revocationObservation(0), authPolarity)++ if verdict.Epistemic != Unsupported {+ t.Fatalf(+ "epistemic = %s, want %s; the target accepted a certificate khaos revoked at its own CA, and reporting that as anything else is either an accusation about a check the platform does not have or a clean bill of health for a revoked certificate in use",+ verdict.Epistemic,+ Unsupported,+ )+ }++ if verdict.Epistemic == Passed {+ t.Fatal("a revoked certificate in active use was reported as a pass")+ }++ if verdict.Direction == Permitted {+ t.Fatal(+ "the verdict accused the target of permitting a bypass, which requires a check to have been bypassed",+ )+ }++ if verdict.Conclusive {+ t.Fatal(+ "an unsupported run was marked conclusive, so the exit code would claim khaos had established something",+ )+ }++ if len(verdict.Reasons) == 0 {+ t.Fatal(+ "the verdict carries no reason, so an operator reading `unsupported` cannot tell whether khaos declined to claim or simply broke",+ )+ }+}++// The other direction, and the one that makes the verdict honest rather than an+// excuse. A target that DID fetch the CRL and then used the certificate anyway+// has a revocation check, and that check failed.+func TestATargetThatCheckedAndAcceptedAnywayIsStillADefect(t *testing.T) {+ verdict := Judge(revocationObservation(12), authPolarity)++ if verdict.Epistemic == Unsupported {+ t.Fatal(+ "a target that fetched khaos's CRL twelve times during the baseline and then accepted a certificate listed in it was excused as unsupported; the check exists and it failed",+ )+ }++ if verdict.Epistemic != Passed && verdict.Epistemic != Deviated {+ t.Fatalf(+ "epistemic = %s; a run with a healthy baseline, a confirmed fault and a consulted endpoint is measurable and has to reach a directional reading",+ verdict.Epistemic,+ )+ }+}++// The guard only applies to experiments that DECLARE the check optional.+// Without that, a never-consulted endpoint would be excused everywhere,+// including for the three introspection experiments whose whole liveness+// problem is that a target doing purely local validation never calls them.+func TestANeverConsultedEndpointIsStillVoidWhenTheCheckIsNotOptional(+ t *testing.T,+) {+ observation := revocationObservation(0)+ observation.Unsupportable = ""++ verdict := Judge(observation, authPolarity)++ if verdict.Epistemic == Unsupported {+ t.Fatal(+ "an experiment that did not declare its check optional got the unsupported reading anyway, which would excuse every fault aimed at an endpoint the target happens not to use",+ )+ }++ if verdict.Epistemic != BaselineNotMet {+ t.Fatalf(+ "epistemic = %s, want %s; a fault aimed at an endpoint the target never touched is a void run",+ verdict.Epistemic,+ BaselineNotMet,+ )+ }+}diff --git a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/verdict.go b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/verdict.goindex 7b46c878..a81a789b 100644--- a/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/verdict.go+++ b/PROJECTS/intermediate/chaos-engineering-tool/internal/experiment/verdict.go@@ -19,6 +19,27 @@ const (Aborted Epistemic = "aborted"Interrupted Epistemic = "interrupted"Errored Epistemic = "error"++ // Unsupported is a clean, well-measured run whose QUESTION does not apply+ // to the target. It is not a pass, not a defect, and not a measurement+ // failure, and conflating it with any of the three is a lie in a different+ // direction each time.+ //+ // It exists because of revocation. Go's crypto/x509 performs no revocation+ // checking of any kind and has no option to turn it on, so a Go target+ // handed a certificate revoked in a valid, in-date, correctly signed CRL+ // from its own issuer accepts it with a nil error. Calling that PERMITTED+ // would accuse the target of skipping a check it never had; calling it+ // PASSED would be worse, because the certificate really was revoked and+ // really was used. Research 04 is explicit: a revoked assertion must report+ // unsupported, never pass.+ //+ // khaos decides this by MEASUREMENT, not by being told the target's+ // language. The authority counts what the target fetched, so "it never+ // asked about revocation" is an observation rather than an assumption, and+ // a target that DID ask and then used the certificate anyway is a genuine+ // defect that still reports as one.+ Unsupported Epistemic = "unsupported")type Direction string@@ -136,6 +157,8 @@ const (reasonInterrupted = "the run was interrupted before it finished, so nothing it measured is conclusive"reasonRollback = "the fault could not be fully reverted, so the target may still be degraded"reasonFaultUnconfirmed = "khaos could not confirm the fault actually took effect, so nothing measured during the run can be attributed to it"++ reasonUnsupported = "the target never performed %s: it did not contact %s once during the baseline, so there was no check to fail and its acceptance is not a defect. khaos makes no security claim here"reasonNothingToRevoke = "the credential this experiment intends to revoke was never accepted during the baseline, so the target was not honouring it and revoking it takes nothing away"reasonActFailed = "khaos could not make its change at the authority, so the credential it went on to measure was never revoked and every acceptance of it was correct"reasonRevokedHonoured = "a credential khaos invalidated at the authority, by %s, was still accepted %d time(s)"@@ -198,6 +221,11 @@ type Observation struct {Consulted int64 `json:"consulted,omitempty"`ConsultedWhat string `json:"consulted_what,omitempty"`+ // Unsupportable names the check whose absence makes a never-consulted+ // endpoint UNSUPPORTED rather than a void run. Only the experiments that+ // probe something no mainstream TLS stack does by default set it.+ Unsupportable string `json:"unsupportable,omitempty"`+// MintedByKhaos records that the valid credential came from khaos's own// identity provider rather than from the operator. It changes only the// wording of one refusal, and that wording is the difference between telling@@ -264,6 +292,18 @@ func epistemic(observation Observation) (Verdict, bool) {return verdict, false}+ // BEFORE endpointNeverConsulted, because the two read the same observation+ // in opposite directions and only the experiment knows which applies. An+ // endpoint the target never touched is a void run for a fault aimed at+ // something the target uses, and the whole answer for one aimed at a check+ // the platform does not implement.+ if reason, absent := checkNotImplemented(observation); absent {+ verdict.Epistemic = Unsupported+ verdict.Reasons = append(verdict.Reasons, reason)++ return verdict, false+ }+if reason, never := endpointNeverConsulted(observation); never {verdict.Epistemic = BaselineNotMetverdict.Reasons = append(verdict.Reasons, reason)@@ -694,6 +734,26 @@ func baselineUnmet(return forgedBaselineUnmet(baseline, expect)}+// checkNotImplemented reports that the target never performed the check this+// experiment probes, for an experiment that declared the check optional.+//+// This is the measured half of the UNSUPPORTED verdict. khaos is not told the+// target's language; it counts what the target fetched from the authority, so+// "it never asked about revocation" is an observation. A target that DID ask+// and then used the certificate anyway falls through to the ordinary+// directional reading and is reported as the defect it is.+func checkNotImplemented(observation Observation) (string, bool) {+ if observation.Unsupportable == "" || observation.Consulted > 0 {+ return "", false+ }++ return sprintf(+ reasonUnsupported,+ observation.Unsupportable,+ observation.ConsultedWhat,+ ), true+}+// endpointNeverConsulted is the liveness guard for a fault applied to an// endpoint rather than to a credential. Without it, three experiments report a// clean survival of a fault the target never experienced.