Skip to content

Modify get_unavailable_ports to avoid KeyError: 'PublicPort' #21

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HatsuMora
Copy link

I was running CTFd in a docker host that had portainer.io running at the same time. And I got an error message containing KeyError: 'PublicPort'.

Once I looked into https://my-https-docker:2376/containers/json?all=1 I could see why the error happened.

The portainer ports looks like this:

"Ports":[
{
"IP":"0.0.0.0",
"PrivatePort":9443,
"PublicPort":9443,
"Type":"tcp"
},
{
"IP":"0.0.0.0",
"PrivatePort":8000,
"PublicPort":5080,
"Type":"tcp"
},
{
"PrivatePort":9000,
"Type":"tcp"
}.

Adding an extra check to verify that the Ports contain the key PublicPort

I was running CTFd in a docker host that had portainer.io running at the same time. And I got an error message containing KeyError: 'PublicPort'. 

Once I looked into https://my-https-docker:2376/containers/json?all=1 I could see why the error happened.

The portainer ports looks like this: 

"Ports":[
   {
      "IP":"0.0.0.0",
      "PrivatePort":9443,
      "PublicPort":9443,
      "Type":"tcp"
   },
   {
      "IP":"0.0.0.0",
      "PrivatePort":8000,
      "PublicPort":5080,
      "Type":"tcp"
   },
   {
      "PrivatePort":9000,
      "Type":"tcp"
}.

Adding an extra check to verify that the Ports contain the key PublicPort
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.

1 participant