Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golang library for validation: folder structure validation #14

Merged
merged 46 commits into from
Aug 17, 2020

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Aug 6, 2020

This PR implements validation of a package's folder structure. Structure of package files is not yet implemented and will be done in a follow up PR.

Related: #4.

@ycombinator
Copy link
Contributor Author

ycombinator commented Aug 6, 2020

@ruflin @mtojek This PR is a WIP but using it in its current state to validate all packages in the @elastic/integrations repo produces the following results. I suspect some of the following validation errors need fixes in the package while others need fixes in the spec. Could you please let me know which is which. Thank you!

Validating package [apache]...
Error: found 7 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/apache/dataset/access/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/apache/dataset/access/agent/stream]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/apache/dataset/access]
   4. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/apache/dataset/error/agent/stream]
   5. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/apache/dataset/error/agent/stream]
   6. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/apache/dataset/error]
   7. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/apache]

Validating package [aws]...
Error: found 21 validation errors:
   1. item [s3.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/cloudtrail/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/cloudtrail/agent/stream]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/cloudtrail]
   4. item [s3.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/cloudwatch_logs/agent/stream]
   5. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/cloudwatch_logs/agent/stream]
   6. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/cloudwatch_logs]
   7. item [s3.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/ec2_logs/agent/stream]
   8. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/ec2_logs/agent/stream]
   9. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/ec2_logs]
  10. item [s3.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/elb_logs/agent/stream]
  11. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/elb_logs/agent/stream]
  12. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/elb_logs]
  13. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/s3access/agent/stream]
  14. item [s3.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/s3access/agent/stream]
  15. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/s3access/agent/stream]
  16. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/s3access]
  17. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/vpcflow/agent/stream]
  18. item [s3.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/vpcflow/agent/stream]
  19. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/vpcflow/agent/stream]
  20. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/aws/dataset/vpcflow]
  21. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/aws]

Validating package [cisco]...
Error: found 7 validation errors:
   1. item [udp.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/cisco/dataset/asa/agent/stream]
   2. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/cisco/dataset/asa]
   3. item [udp.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/cisco/dataset/ftd/agent/stream]
   4. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/cisco/dataset/ftd]
   5. item [syslog.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/cisco/dataset/ios/agent/stream]
   6. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/cisco/dataset/ios]
   7. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/cisco]

Validating package [crowdstrike]...
Error: found 5 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/crowdstrike/dataset/falcon/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/crowdstrike/dataset/falcon/agent/stream]
   3. item [test] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/crowdstrike/dataset/falcon]
   4. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/crowdstrike/dataset/falcon]
   5. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/crowdstrike]

Validating package [haproxy]...
Error: found 5 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/haproxy/dataset/log/agent/stream]
   2. item [syslog.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/haproxy/dataset/log/agent/stream]
   3. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/haproxy/dataset/log/agent/stream]
   4. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/haproxy/dataset/log]
   5. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/haproxy]

Validating package [iis]...
Error: found 5 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/iis/dataset/access/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/iis/dataset/access/agent/stream]
   3. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/iis/dataset/error/agent/stream]
   4. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/iis/dataset/error/agent/stream]
   5. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/iis]

Validating package [kafka]...
Error: found 4 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/kafka/dataset/log/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/kafka/dataset/log/agent/stream]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/kafka/dataset/log]
   4. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/kafka]

Validating package [kubernetes]...
Error: found 1 validation error:
   1. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/kubernetes]

Validating package [log]...
Error: found 2 validation errors:
   1. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/log/dataset/log]
   2. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/log]

Validating package [mongodb]...
Error: found 3 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/mongodb/dataset/log/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/mongodb/dataset/log/agent/stream]
   3. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/mongodb]

Validating package [mysql]...
Error: found 5 validation errors:
   1. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/mysql/dataset/error]
   2. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/mysql/dataset/slowlog/elasticsearch/ingest_pipeline]
   3. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/mysql/dataset/slowlog/elasticsearch/ingest_pipeline]
   4. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/mysql/dataset/slowlog]
   5. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/mysql]

Validating package [netflow]...
Error: found 4 validation errors:
   1. item [netflow.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/netflow/dataset/log/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/netflow/dataset/log/agent/stream]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/netflow/dataset/log]
   4. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/netflow]

Validating package [nginx]...
Error: found 5 validation errors:
   1. item [test] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/nginx/dataset/access]
   2. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/nginx/dataset/access]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/nginx/dataset/error]
   4. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/nginx/dataset/ingress_controller]
   5. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/nginx]

Validating package [postgresql]...
Error: found 4 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/postgresql/dataset/log/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/postgresql/dataset/log/agent/stream]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/postgresql/dataset/log]
   4. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/postgresql]

Validating package [prometheus]...
Error: found 1 validation error:
   1. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/prometheus]

Validating package [rabbitmq]...
Error: found 4 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/rabbitmq/dataset/log/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/rabbitmq/dataset/log/agent/stream]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/rabbitmq/dataset/log]
   4. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/rabbitmq]

Validating package [redis]...
Error: found 7 validation errors:
   1. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/log/elasticsearch/ingest_pipeline]
   2. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/log/elasticsearch/ingest_pipeline]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/log]
   4. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/slowlog/elasticsearch/ingest_pipeline]
   5. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/slowlog/elasticsearch/ingest_pipeline]
   6. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/slowlog]
   7. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/redis]

Validating package [suricata]...
Error: found 4 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/suricata/dataset/eve/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/suricata/dataset/eve/agent/stream]
   3. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/suricata/dataset/eve]
   4. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/suricata]

Validating package [system]...
Error: found 27 validation errors:
   1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/auth/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/auth/agent/stream]
   3. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/auth/elasticsearch/ingest_pipeline]
   4. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/auth]
   5. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/core]
   6. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/cpu]
   7. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/diskio]
   8. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/entropy]
   9. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/filesystem]
  10. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/fsstat]
  11. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/load]
  12. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/memory]
  13. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/network]
  14. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/network_summary]
  15. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/process]
  16. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/process_summary]
  17. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/raid]
  18. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/service]
  19. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/socket]
  20. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/socket_summary]
  21. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/syslog/agent/stream]
  22. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/syslog/agent/stream]
  23. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/syslog/elasticsearch/ingest_pipeline]
  24. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/syslog]
  25. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/uptime]
  26. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/users]
  27. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/system]

Validating package [windows]...
Error: found 3 validation errors:
   1. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/windows/dataset/perfmon]
   2. expecting to find [sample_event.json] file in folder [/Users/shaunak/development/github/integrations/packages/windows/dataset/service]
   3. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/windows]

Validating package [zookeeper]...
Error: found 1 validation error:
   1. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/zookeeper]

@mtojek
Copy link
Contributor

mtojek commented Aug 10, 2020

Let me refer to errors. I'm afraid all of them slipped through the review phase.

  1. Item is not allowed in folder
1. item [log.yml.hbs] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/apache/dataset/access/agent/stream]
   2. expecting to find [stream.yml.hbs] file in folder [/Users/shaunak/development/github/integrations/packages/apache/dataset/access/agent/stream]

I think this is a valid file. Take a look at the manifest.yml file for the given dataset. It has a reference to it (template_path: log.yml.hbs).

  1. Missing sample_event.json file
expecting to find [sample_event.json] file in folder

This is optional at the moment. You can use this file to render samples in docs. I'm not convinces whether it should be mandatory or not.

  1. Expecting to find [changelog.yml] file in folder
   4. expecting to find [changelog.yml] file in folder [/Users/shaunak/development/github/integrations/packages/suricata]

I'm allergic to changelogs, probably @ruflin would like to elaborate on them :) I suppose we will have to start using them, but I'm not sure if people get mad, when you ask them to fill them up.

code/go/internal/validator/folder.go Outdated Show resolved Hide resolved

// ValidateFromPath validates a package located at the given path against the
// appropriate specification and returns any errors.
func ValidateFromPath(packageRootPath string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the method I was referring in different PR: ValidateFromPath. I would be cool not to load specs every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, see my reply on the other PR: #12 (comment). Let's continue the conversation there.

code/go/pkg/validator/validator.go Show resolved Hide resolved
code/go/internal/validator/spec.go Outdated Show resolved Hide resolved
@ruflin
Copy link
Contributor

ruflin commented Aug 10, 2020

@mtojek For changelog: We need a way to tell users of the packages on what change between versions. I'm not tied at all to changelogs but we need a solution.

@ycombinator
Copy link
Contributor Author

My 2 cents: I like the proposed CHANGELOG yml format. It captures what we need, but in a structured fashion. So one can imagine generating human-readable changelog documentation from it, etc.

I'm allergic to changelogs,

@mtojek could you elaborate on why this is? maybe there's a drawback that I'm not seeing currently.

@elasticmachine
Copy link

elasticmachine commented Aug 10, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #14 updated]

  • Start Time: 2020-08-14T19:37:49.549+0000

  • Duration: 2 min 0 sec

@ycombinator
Copy link
Contributor Author

ycombinator commented Aug 11, 2020

I've created #17 so we can have a discussion dedicated to changelogs over there. I'll copy over relevant comments from here so they are readily available.

@mtojek
Copy link
Contributor

mtojek commented Aug 12, 2020

I'm fine with taking the CHANGELOG discussion out the scope of this PR. I believe you can mark it as optional or temporarily remove its definition from spec.

@mtojek
Copy link
Contributor

mtojek commented Aug 12, 2020

CI complains about missing comments:

[2020-08-11T22:30:57.434Z] /var/lib/jenkins/workspace/Beats_package-spec_PR-14/src/github.com/elastic/package-spec/code/go/internal/validator/package.go:14:6: exported type Package should have comment or be unexported
[2020-08-11T22:30:57.434Z] /var/lib/jenkins/workspace/Beats_package-spec_PR-14/src/github.com/elastic/package-spec/code/go/internal/validator/package.go:19:1: exported function NewPackage should have comment or be unexported
[2020-08-11T22:30:57.434Z] /var/lib/jenkins/workspace/Beats_package-spec_PR-14/src/github.com/elastic/package-spec/code/go/internal/validator/spec.go:12:2: a blank import should be only in a main or test package, or have a comment justifying it
[2020-08-11T22:30:57.434Z] /var/lib/jenkins/workspace/Beats_package-spec_PR-14/src/github.com/elastic/package-spec/code/go/internal/validator/spec.go:15:6: exported type Spec should have comment or be unexported
[2020-08-11T22:30:57.435Z] /var/lib/jenkins/workspace/Beats_package-spec_PR-14/src/github.com/elastic/package-spec/code/go/internal/validator/spec.go:21:1: exported function NewSpec should have comment or be unexported
[2020-08-11T22:30:57.435Z] /var/lib/jenkins/workspace/Beats_package-spec_PR-14/src/github.com/elastic/package-spec/code/go/internal/validator/spec.go:43:1: exported method Spec.ValidatePackage should have comment or be unexported

@ruflin
Copy link
Contributor

ruflin commented Aug 13, 2020

++ on skipping changelog and follow up.

@ycombinator
Copy link
Contributor Author

ycombinator commented Aug 13, 2020

After making updates to the folder validation per review feedback, validating all existing packages in the @elastic/integrations repository with this PR produces the following results.

Validating package [apache]...
Validating package [aws]...
Validating package [checkpoint]...
Validating package [cisco]...
Validating package [crowdstrike]...
Error: found 1 validation error:
   1. item [test] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/crowdstrike/dataset/falcon]

Validating package [fortinet]...
Error: found 3 validation errors:
   1. item [event.yml] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/fortinet/dataset/firewall/elasticsearch/ingest_pipeline]
   2. item [traffic.yml] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/fortinet/dataset/firewall/elasticsearch/ingest_pipeline]
   3. item [utm.yml] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/fortinet/dataset/firewall/elasticsearch/ingest_pipeline]

Validating package [haproxy]...
Validating package [iis]...
Validating package [kafka]...
Validating package [kubernetes]...
Validating package [log]...
Validating package [microsoft]...
Validating package [mongodb]...
Validating package [mysql]...
Error: found 2 validation errors:
   1. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/mysql/dataset/slowlog/elasticsearch/ingest_pipeline]
   2. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/mysql/dataset/slowlog/elasticsearch/ingest_pipeline]

Validating package [netflow]...
Validating package [nginx]...
Error: found 1 validation error:
   1. item [test] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/nginx/dataset/access]

Validating package [o365]...
Validating package [okta]...
Validating package [panw]...
Validating package [postgresql]...
Validating package [prometheus]...
Validating package [rabbitmq]...
Validating package [redis]...
Error: found 4 validation errors:
   1. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/log/elasticsearch/ingest_pipeline]
   2. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/log/elasticsearch/ingest_pipeline]
   3. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/slowlog/elasticsearch/ingest_pipeline]
   4. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/slowlog/elasticsearch/ingest_pipeline]

Validating package [suricata]...
Validating package [system]...
Error: found 2 validation errors:
   1. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/auth/elasticsearch/ingest_pipeline]
   2. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/syslog/elasticsearch/ingest_pipeline]

Validating package [windows]...
Validating package [zookeeper]...

As you can see most packages are now valid, which is nice! Let's go through the remaining errors reported above.

Validating package [crowdstrike]...
Error: found 1 validation error:
   1. item [test] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/crowdstrike/dataset/falcon]
...
Validating package [nginx]...
Error: found 1 validation error:
   1. item [test] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/nginx/dataset/access]

I think we have to allow this for now. There is a discussion I have started (#22) that might impact this validation but for now, I think we add it. I will update this PR to do so but just wanted to call it out here first in case anyone has any objections.

Validating package [fortinet]...
Error: found 3 validation errors:
  1. item [event.yml] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/fortinet/dataset/firewall/elasticsearch/ingest_pipeline]
  2. item [traffic.yml] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/fortinet/dataset/firewall/elasticsearch/ingest_pipeline]
  3. item [utm.yml] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/fortinet/dataset/firewall/elasticsearch/ingest_pipeline]

I checked and the fortinet package's firewall dataset does define a default.yml ingest pipeline. This pipeline references the other three pipelines shown above. So I believe it's okay to have these files in there as long as Kibana knows to load these additional ingest pipelines into Elasticsearch. @ruflin can you confirm this, please?

Validating package [mysql]...
Error: found 2 validation errors:
   1. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/mysql/dataset/slowlog/elasticsearch/ingest_pipeline]
   2. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/mysql/dataset/slowlog/elasticsearch/ingest_pipeline]
...
Validating package [redis]...
Error: found 4 validation errors:
   1. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/log/elasticsearch/ingest_pipeline]
   2. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/log/elasticsearch/ingest_pipeline]
   3. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/slowlog/elasticsearch/ingest_pipeline]
   4. expecting to find [default.yml] file in folder [/Users/shaunak/development/github/integrations/packages/redis/dataset/slowlog/elasticsearch/ingest_pipeline]
...
Validating package [system]...
Error: found 2 validation errors:
   1. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/auth/elasticsearch/ingest_pipeline]
   2. item [default.json] is not allowed in folder [/Users/shaunak/development/github/integrations/packages/system/dataset/syslog/elasticsearch/ingest_pipeline]

So these errors look like a case of ingest pipelines being defined as JSON instead of YAML. What do we want to do here? I know Beats could accept either format — is this what we want for Packages too? or do we want to require that packages only define their ingest pipelines in YAML (in which case the above ingest pipelines will need to be converted to YAML)?

Also, I assume Kibana is able to load ingest pipelines from either format into Elasticsearch? @ruflin?

@ruflin
Copy link
Contributor

ruflin commented Aug 14, 2020

Kibana knows how to load multiple ingest pipelines. @skh @neptunian to make sure this is correct.

For json vs yaml: I think we should support both. Yaml allows us when we build ingest pipelines from scratch to add comments etc, but users just exporting pipelines from Elasticsearch and copy / paste it to a package will likely use json. Kibana supports both formats. (@skh )

@neptunian
Copy link

Kibana knows how to load multiple ingest pipelines. @skh @neptunian to make sure this is correct.

Yes. The ingest manager will install all pipelines in the ingest_pipeline directory, not just the default or entry pipeline.

For json vs yaml: I think we should support both. Yaml allows us when we build ingest pipelines from scratch to add comments etc, but users just exporting pipelines from Elasticsearch and copy / paste it to a package will likely use json. Kibana supports both formats.

Yes, both formats are supported.

@ycombinator
Copy link
Contributor Author

Thanks @ruflin and @neptunian for weighing in. Based on your feedback, I have now updated this PR. And as a result all integrations packages are now passing validation on this PR!

Validating package [apache]...
Validating package [aws]...
Validating package [checkpoint]...
Validating package [cisco]...
Validating package [crowdstrike]...
Validating package [fortinet]...
Validating package [haproxy]...
Validating package [iis]...
Validating package [kafka]...
Validating package [kubernetes]...
Validating package [log]...
Validating package [microsoft]...
Validating package [mongodb]...
Validating package [mysql]...
Validating package [netflow]...
Validating package [nginx]...
Validating package [o365]...
Validating package [okta]...
Validating package [panw]...
Validating package [postgresql]...
Validating package [prometheus]...
Validating package [rabbitmq]...
Validating package [redis]...
Validating package [suricata]...
Validating package [system]...
Validating package [windows]...
Validating package [zookeeper]...

@mtojek @ruflin would you mind re-reviewing this PR please? Thanks!

@ycombinator ycombinator requested review from mtojek and ruflin August 14, 2020 19:52
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved!

Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets get this in, run it on all packages moving forward and iterate.

@ycombinator ycombinator merged commit 596ecfd into elastic:master Aug 17, 2020
@ycombinator ycombinator deleted the lib-golang-folder-validation branch August 17, 2020 18:32
@ycombinator ycombinator mentioned this pull request Sep 17, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants