DataDog / KubeHound

Kubernetes Attack Graph
https://kubehound.io
Apache License 2.0
703 stars 36 forks source link

Refactor writers (multi-thread + enveloped k8s type_ #172

Closed jt-dd closed 3 months ago

jt-dd commented 3 months ago

Refactor the writer to be compatible with the collector. The collector needs to have an abstract layer k8sTypeList, so it means we can no longer dump raw files directly, we need to consolidate all the entries for each files first.

For the file writer, we build a buffer for each file, then write it to the filesystem [buffer -> raw fs.FS] For the tar writer, there is one more step, instead of writing directly to the tar, we write the file to a "memory fs" using afero lib. [buffer --> aerofs FS --> tar fs.FS]

This allows to support for both writer, partial multi-threading.