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

Run changeme outside of project directory #45

Closed
sil3ntcor3 opened this issue Oct 7, 2017 · 3 comments
Closed

Run changeme outside of project directory #45

sil3ntcor3 opened this issue Oct 7, 2017 · 3 comments
Assignees
Labels

Comments

@sil3ntcor3
Copy link
Contributor

Changeme fails to run with the following output:

/opt/changeme/changeme.py -d PTDS_scan_1.xml

[09:12:21][core][_validate_args] Delay is set to 500 milliseconds
[09:12:21][core][_validate_args] http
[09:12:23][core][check_version] Unable to retrieve latest changeme version.
Traceback (most recent call last):
File "/opt/changeme/changeme.py", line 6, in
core.main()
File "/opt/changeme/changeme/core.py", line 48, in main
creds = load_creds(config)
File "/opt/changeme/changeme/core.py", line 260, in load_creds
protocols = next(os.walk('creds'))[1]
StopIteration

/opt/changeme/changeme.py -d 10.154.1.1

[13:40:18][core][_validate_args] Delay is set to 500 milliseconds
[13:40:18][core][_validate_args] http
[13:40:20][core][check_version] Unable to retrieve latest changeme version.
Traceback (most recent call last):
File "/opt/changeme/changeme.py", line 6, in
core.main()
File "/opt/changeme/changeme/core.py", line 48, in main
creds = load_creds(config)
File "/opt/changeme/changeme/core.py", line 260, in load_creds
protocols = next(os.walk('creds'))[1]
StopIteration

@ztgrace
Copy link
Owner

ztgrace commented Oct 8, 2017

Thanks for the bug report. So according to the Python documentation, a generator in python should always raise a StopIteration exception when there's no more values in the generator. Some built-in functions like for automatically handle this exception and terminate the loop. Since I was calling next directly, the uncaught exception gets raised. Now the crazy part is that the error and this is some of the oldest code in changeme and I'm baffled why this doesn't throw an exception all of the time and you're the first to hit this error.

Until 1.0.3 gets published, swapping line 260 with protocols = [proto for proto in os.walk('creds')][0][1] or running the development branch should fix the issue.

@sil3ntcor3
Copy link
Contributor Author

Looks like I'm getting a newish error now. I tried both the swapping line 260 with the new code and running the dev branch.

Traceback (most recent call last):
File "/opt/changeme/changeme.py", line 6, in
core.main()
File "/opt/changeme/changeme/core.py", line 48, in main
creds = load_creds(config)
File "/opt/changeme/changeme/core.py", line 260, in load_creds
protocols = [ proto for proto in os.walk('creds')][0][1]
IndexError: list index out of range

@ztgrace
Copy link
Owner

ztgrace commented Oct 8, 2017

Ok, I can finally reproduce it (I was shooting in the dark earlier). It looks like you're running /opt/changeme/changeme.py from outside of the project directory /opt/changeme/. So if you cd /opt/changeme/ then run ./changeme.py -d PTDS_scan_1.xml it should work better for you.

I'm going to rename this issue to better reflect the issue and work on getting this resolved for the next release.

Thanks again for the bug report and troubleshooting.

@ztgrace ztgrace changed the title Failing to run: line 260, in load_creds Run changeme outside of project directory Oct 8, 2017
@ztgrace ztgrace added the bug label Oct 8, 2017
@ztgrace ztgrace self-assigned this Oct 8, 2017
@ztgrace ztgrace mentioned this issue Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants