mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
7dc514b52f2c96bdd1ea32ae64a02703f85be2aa
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
97cbce205b |
feat(config): add aggregation authorization CRUD (#3627)
* feat(config): add aggregation authorization CRUD PutAggregationAuthorization, DescribeAggregationAuthorizations and DeleteAggregationAuthorization were unrouted, so the JSON handler answered InvalidAction and aws_config_aggregate_authorization could not be created. Authorizations are keyed by (AuthorizedAccountId, AuthorizedAwsRegion) within the request region, persisted through StorageFactory like the other durable Config resources. Put is an upsert that preserves the ARN and creation time of an existing authorization, and accepts Tags, which land in the same tag store that ListTagsForResource reads. Delete of an absent authorization succeeds: the Config model declares no not-found error for that operation. * fix(config): remove aggregation-authorization tags on every delete attempt Tag cleanup ran only when the delete found an entry to remove. A delete that removed the authorization but did not reach the tags left them behind, and the retry that should have cleaned them up skipped the cleanup because the entry was already gone. Put reuses a deterministic ARN, so those tags reappeared on the next authorization for the same account and region. The ARN is now derived from the key instead of read off the removed entry, and its tags are dropped on every attempt. The authorization map is still persisted only when an entry was actually removed. * fix(config): apply PutAggregationAuthorization tags at creation only PutAggregationAuthorization is idempotent, and AWS applies request tags at creation only: a later Put that finds the authorization already there ignores its Tags and leaves the existing ones alone. Tagging the existing ARN on every Put let a local test retag by re-putting, which production would silently refuse. Return the existing authorization untouched and tag only the one just created. Tags still change through TagResource/UntagResource, which is the only way AWS offers. * fix(config): make aggregation authorization put/delete atomic putAggregationAuthorization did a get-then-put on the region map with nothing holding the two together, and deleteAggregationAuthorization removed-then- persisted the same way. Two concurrent Puts for one (AuthorizedAccountId, AuthorizedAwsRegion) could both find nothing and both create: the second overwrote the first's CreationTime and re-applied creation tags over a set TagResource may already have changed, so the documented idempotency held only probabilistically. Both now take the same per-key lock putConfigRule/deleteConfigRule already use for rules. The lock keys are namespaced apart from the rule keys in the shared map rather than relying on rule names never containing '|'. The regression runs many short rounds rather than one wide one, because the unlocked window is a few instructions: repeated fresh starts land the race, more threads on one start do not. It asserts reference identity, which is what distinguishes the two cases -- the store is keyed on the pair so its size is 1 either way, the ARN is derived from the key so it is equal either way, and CreationTime is epoch seconds so a racing pair created inside one second is indistinguishable by timestamp. Verified to fail with the lock removed (17 mismatches) and pass with it, five runs. |
||
|
|
1b3417a7a3 |
feat(config): compliance evaluation loop, retention, pagination (#2642)
* feat(config): add compliance evaluation loop, retention, and pagination Replace the hardcoded INSUFFICIENT_DATA compliance with real aggregation over evaluations reported via PutEvaluations / PutExternalEvaluation: - New actions (13): PutEvaluations, PutExternalEvaluation, DeleteEvaluationResults, DescribeComplianceByResource, GetComplianceDetailsByConfigRule, GetComplianceDetailsByResource, GetComplianceSummaryByConfigRule, GetComplianceSummaryByResourceType, DeleteConfigurationRecorder, DeleteDeliveryChannel, PutRetentionConfiguration, DescribeRetentionConfigurations, DeleteRetentionConfiguration - PutConfigRule now round-trips the full AWS rule shape (Description, Scope, SourceDetails, InputParameters, MaximumExecutionFrequency, EvaluationModes) instead of silently dropping fields - Evaluations persist to config-evaluations.json and are cascade-deleted with their rule; retention persists to config-retention.json - NextToken/Limit pagination on describe/get operations with AWS page sizes and InvalidNextTokenException/InvalidLimitException validation - DescribeConfigRules with an unknown name now fails with NoSuchConfigRuleException, matching AWS - boto3 compatibility suite: tests/test_config.py Since Floci performs no Lambda invocation, PutEvaluations accepts the config rule name as the ResultToken; documented in the service doc's deviations section. * fix: honor Limit field in Config pagination requests * fix(config): enforce the modeled rule enums and the ComplianceTypes filter shape PutConfigRule now deserializes the whole modeled ConfigRule and stores it, so Source.Owner, MaximumExecutionFrequency, ConfigRuleState and EvaluationModes[].Mode were persisted and echoed back verbatim — a rule AWS would have rejected with InvalidParameterValueException read back as a valid one. The ComplianceTypes filter on the four compliance reads was likewise unchecked: an unmodeled value or a list longer than the shape's max of 3 simply matched nothing, which a caller reads as an empty result rather than as a rejection. * fix(config): validate the nested SourceDetails enums and Scope cardinality The stored ConfigRule carries SourceDetails, whose EventSource (aws.config only), MessageType and MaximumExecutionFrequency are all enum-typed, and a Scope whose ComplianceResourceTypes list is capped at 100. All four were persisted and echoed back by DescribeConfigRules verbatim, one level below the members the previous commit checked. * fix(config): reject a missing ConfigRuleName on DeleteConfigRule store.remove(ruleName) throws NullPointerException on the backing ConcurrentHashMap when ruleName is null (the handler passes null when ConfigRuleName is absent from the request), producing a 500 instead of the modeled NoSuchConfigRuleException. Guard on isBlank(ruleName) first, matching the existing requireRule() idiom used by the sibling evaluation operations for the same field. * fix(config): keep the newest evaluation when PutEvaluations reorders storeEvaluations() unconditionally overwrote the stored compliance result for a resource/rule pair, so an older evaluation arriving after a newer one (e.g. an out-of-order Lambda invocation) regressed compliance details, aggregates, and summaries back to the stale value. Compare against the stored OrderingTimestamp and skip the incoming evaluation when it is older than what is already recorded. * fix(config): make PutEvaluations atomic per resource/rule key storeEvaluations() read the current evaluation with a plain get() and wrote the new one with a separate put(), so two concurrent PutEvaluations calls for the same resource could both read the old value before either wrote, letting an older OrderingTimestamp win the race regardless of arrival order. Replace the read-then-write with ConcurrentHashMap.compute(), which is atomic per key. Added a stress test exercising 16 concurrent writers per resource key across 100 attempts; it passes reliably under the fix. The race window in the prior get/put shape is narrow enough (a handful of nanoseconds between the two calls) that it did not reproduce deterministically under test scheduling even with that much contention -- the fix is justified by the non-atomic read-then-write shape itself, not by a forced failure. * fix(config): enforce DescribeConfigRules' 25-name limit ConfigRuleNames is modeled with Maximum 25 items (confirmed against botocore's config service-2.json) but describeConfigRules had no size check, so 26+ names were processed instead of rejected with InvalidParameterValueException like every other array-size limit this PR already enforces. * fix(config): close the DeleteConfigRule/PutEvaluations deletion race PutEvaluations (and PutExternalEvaluation, DeleteEvaluationResults) checked a rule's existence via requireRule and then wrote to the evaluations map as two separate steps. If DeleteConfigRule ran in between -- removing the rule and its evaluation bucket -- the pending PutEvaluations call would recreate the bucket via computeIfAbsent after the delete, orphaning evaluations under the deleted rule's name. A later rule created with that same name would then inherit the deleted rule's compliance details and evaluation status. Guard the check-then-act with a per-rule monitor (ruleKey(region, ruleName)), matching the lockFor()-keyed-monitor idiom already used by DocDbService for the identical class of race between a tag update and a delete. Added a stress test racing PutEvaluations against DeleteConfigRule across 200 attempts, then recreating the rule under the same name and asserting a clean (INSUFFICIENT_DATA) evaluation state. It passes under the fix; as with the earlier PutEvaluations-ordering race, it did not reproduce RED against the pre-fix code even under that much contention -- the race window between the existence check and the map write is too narrow to hit deterministically without injecting an artificial delay into production code. The fix is justified by the non-atomic check-then-act shape itself, confirmed by reading the code. |
||
|
|
96a6fa6517 |
feat(config): add AWS Config service emulation (#934)
* feat(config): add AWS Config service emulation (#913) * docs: add AWS Config service page and align service counts across all docs Add docs/services/config.md with all 20 supported actions, CLI examples, and configuration reference. Add 5 services that had doc pages but were missing from the service matrix (Textract, Pricing, Cost Explorer, CUR, BCM Data Exports). Reconcile service count to 51 across README, docs/index.md, and docs/services/index.md. |