OpenSCAP / yaml-filter

YAML document filtering for libyaml
MIT License
2 stars 9 forks source link

Error getting key: Expected DOCUMENT-END #2

Closed yuumasato closed 4 years ago

yuumasato commented 4 years ago

From master branch using this file, I get error: Emitter error: expected DOCUMENT-END Am I doing something wrong?

$ ./yamlp -f ~/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.metadata'
name: instance
namespace: openshift-logging

$ ./yamlp -f ~/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.metadata.namespace'
openshift-logging

$ ./yamlp -f ~/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.metadata.name'
Emitter error: expected DOCUMENT-END
yuumasato commented 4 years ago

This may have the same root cause:

$ ./yamlp -f ~/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.spec.outputs'
- type: "elasticsearch"
  name: elasticsearch
  endpoint: elasticsearch.openshift-logging.svc:9200
  mode: 066
  secret:
    name: fluentd
- type: "elasticsearch"
  name: elasticsearch-insecure
  endpoint: elasticsearch-insecure.svc.messaging.cluster.local
  mode: "066"
  insecure: true
- type: "forward"
  name: secureforward-offcluster
  endpoint: https://secureforward.offcluster.com:9200
  mode: "067"
  secret:
    name: secureforward

$ ./yamlp -f ~/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.spec.outputs[0]'
Emitter error: expected DOCUMENT-END

$ ./yamlp -f ~/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.spec.outputs[1]'
Emitter error: expected DOCUMENT-END

$ ./yamlp -f ~/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.spec.outputs[2]'
Emitter error: expected DOCUMENT-END
jan-cerny commented 4 years ago

Hi @evgenyz , #4 doesn't fix this problem for me, can you take a look at it?

evgenyz commented 4 years ago

It should be fixed with #5, I've merged it, can you please check. If it is not, please give me the path which breaks things.

yuumasato commented 4 years ago

@evgenyz The use cases mentioned in this issue work for me, with yamlp.

evgenyz commented 4 years ago

@jan-cerny Does it fix your problem as well?

jan-cerny commented 4 years ago

Hi @evgenyz , it seems that it fixes the case reported by @yuumasato . But with the yamlpaths that we use in OpenSCAP tests in test_probes_yamlfilecontent_array.xml it still triggers this error message:

./yamlp -f ~/work/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.spec.outputs[2].name'
Emitter error: expected DOCUMENT-END

./yamlp -f ~/work/git/openscap/tests/probes/yamlfilecontent/openshift-logging.yaml '.spec.outputs[0:2].name'
Emitter error: expected DOCUMENT-END

Can you check these as well?

evgenyz commented 4 years ago

OK, these should be fixed by https://github.com/OpenSCAP/yaml-filter/commit/a4a934fc814059cccd014cc64ae809dc46c97aa6

jan-cerny commented 4 years ago

@evgenyz Thanks, I confirm the issue from previous comment is fixed. Also, it makes the failing test for yamlfilecontent probe passing (well almost passing, there was also a small mistake in the test OVAL xml which I fixed in https://github.com/OpenSCAP/openscap/pull/1480/commits/75d720b30bf9c7f55bfd16f7ee87a0a512330c8c)