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

Running gixy on stdin does not work #110

Open
polyatail opened this issue May 28, 2020 · 0 comments
Open

Running gixy on stdin does not work #110

polyatail opened this issue May 28, 2020 · 0 comments

Comments

@polyatail
Copy link

polyatail commented May 28, 2020

It seems to stem from this section, specifically:

    for input_path in args.nginx_files:
        path = os.path.abspath(os.path.expanduser(input_path))
        if not os.path.exists(path):
            LOG.error('File %s was not found', path)
            continue

        with Gixy(config=config) as yoda:
            try:
                if path == '-':
                    with os.fdopen(sys.stdin.fileno(), 'rb') as fdata:
                        yoda.audit('<stdin>', fdata, is_stdin=True)

The part where input_path might be a hypen and os.path.abspath("-") will yield $PWD/- rather than a hypen alone. In the conditional below, path can never be -.

Here's what the Python docs have to say:

Return a normalized absolutized version of the pathname path.
On most platforms, this is equivalent to calling the function normpath() as follows:

normpath(join(os.getcwd(), path)).

For reference, this was on MacOS 10.15.3. Perhaps it is different on other platforms.

polyatail pushed a commit to polyatail/gixy that referenced this issue May 28, 2020
…ndex#110.

Also drops redundant check that files exist before processing, and checks that file paths are not specified at the same time as stdin.
dvershinin added a commit to dvershinin/gixy that referenced this issue Jan 15, 2023
Refactor input validation to accept stdin on all platforms. Closes yandex#110.
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

No branches or pull requests

1 participant