Closed msecrfe closed 2 months ago
Hi @rf-mgb! If you would mind opening a PR to fix it I'll gladly approve. If not you could share the details of why is it failing and I could check it at some point
I have a small patch that just prevents crashes and ignores malformed resources. This likely means that some resources will be ignored by PurplePanda but at least the scan manages to continue:
--- a/intel/google/discovery/gcp_disc_client.py
+++ b/intel/google/discovery/gcp_disc_client.py
@@ -308,9 +308,12 @@ class GcpDiscClient(PurplePanda):
m_objs = p_obj.get_basic_owners()
elif member.startswith("principal:") or member.startswith("principalSet:"):
- name = member.replace("principal:", "").replace("principalSet:", "")
- m_obj: GcpWorkloadIdentityPool = GcpWorkloadIdentityPool(name=name).save()
- m_objs = [m_obj]
+ if "/projects/" in member:
+ name = member.replace("principal:", "").replace("principalSet:", "")
+ m_obj: GcpWorkloadIdentityPool = GcpWorkloadIdentityPool(name=name).save()
+ m_objs = [m_obj]
+ else:
+ continue
elif member.startswith("deleted:"):
continue
Do you want me to open a PR for this small patch or do you want to quickly add this little diff yourself?
Just to reiterate, with this patch PurplePanda will likely not gather certain resources (like the example above, //iam.googleapis.com/locations/global/workforcePools/<CENSORED>-workforce-pool/subject/<CENSORED>@<CENSORED>.<CENSORED>
).
I merged some code that hopefully will fix this, please, retry it and reopen this or any issue if you note that some issue is still not fixed!
Hi Carlos,
I ran PurplePanda on our GCP environment. During the
disc_projects
step, when PurplePanda tries to instantiate aGcpWorkloadIdentityPool
object, it crashes with an IndexError (out of range) on the following line:name_part = name.split("/projects/")[1]
Full trace:
I added a few print statements to see which name triggers this error. The name looks as follows:
//iam.googleapis.com/locations/global/workforcePools/<CENSORED>-workforce-pool/subject/<CENSORED>@<CENSORED>.<CENSORED>
It seems that the constructor of
GcpWorkloadIdentityPool
cannot deal with a name that is formatted this way. It seems to expect one that has the string/projects/
in it.