Repository: cloud-custodian/cloud-custodian

Issue:
NoneType Issue
I dropped a yaml file into a new OU/SubOU and its not working, though it works in other OUs just fine.   Nothing was changed in the file but I am still getting this error, not sure why.

```
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.9.12/bin/custodian", line 8, in <module>
    sys.exit(main())
  File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/c7n/cli.py", line 363, in main
    command(config)
  File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/c7n/commands.py", line 219, in validate
    structure.validate(data)
  File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/c7n/structure.py", line 48, in validate
    self.validate_policy(p)
  File "/root/.pyenv/versions/3.9.12/lib/python3.9/site-packages/c7n/structure.py", line 78, in validate_policy
    for a in p.get('actions', ()):
TypeError: 'NoneType' object is not iterable
```

Discussion:

Patch:
diff --git a/c7n/structure.py b/c7n/structure.py
index 3f6ec12d0..d9f72901f 100644
--- a/c7n/structure.py
+++ b/c7n/structure.py
@@ -66,7 +66,7 @@ class StructureParser:
                 'policy:%s must use a list for filters found:%s' % (
                     p['name'], type(p['filters']).__name__)))
         element_types = (dict, str)
-        for f in p.get('filters', ()):
+        for f in p.get('filters', ()) or []:
             if not isinstance(f, element_types):
                 raise PolicyValidationError((
                     'policy:%s filter must be a mapping/dict found:%s' % (
@@ -75,7 +75,7 @@ class StructureParser:
             raise PolicyValidationError((
                 'policy:%s must use a list for actions found:%s' % (
                     p.get('name', 'unknown'), type(p['actions']).__name__)))
-        for a in p.get('actions', ()):
+        for a in p.get('actions', ()) or []:
             if not isinstance(a, element_types):
                 raise PolicyValidationError((
                     'policy:%s action must be a mapping/dict found:%s' % (


Test patch:
diff --git a/tests/test_schema.py b/tests/test_schema.py
index b46e2b355..f7f7de555 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -73,6 +73,14 @@ class StructureParserTest(BaseTest):
         self.assertTrue(str(ecm.exception).startswith(
             'policy:foo action must be a mapping/dict found:list'))
 
+    def test_null_actions(self):
+        p = StructureParser()
+        p.validate({'policies': [{'name': 'foo', 'resource': 'ec2', 'actions': None}]})
+
+    def test_null_filters(self):
+        p = StructureParser()
+        p.validate({'policies': [{'name': 'foo', 'resource': 'ec2', 'filters': None}]})
+
     def test_invalid_filter(self):
         p = StructureParser()
         with self.assertRaises(PolicyValidationError) as ecm: