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

Table challenge missing #22

Open
noraj opened this issue Sep 25, 2017 · 10 comments
Open

Table challenge missing #22

noraj opened this issue Sep 25, 2017 · 10 comments

Comments

@noraj
Copy link
Contributor

noraj commented Sep 25, 2017

I'm not in production (didn't put PRODUCTION=1) so the app must use dev.db SQLite databse.

But peewee found that there is no such table: challenge.

$ ./ctftool challenges add problem.yml
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.OperationalError: no such table: challenge

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./ctftool", line 248, in <module>
    main()
  File "./ctftool", line 244, in main
    args.func(args)
  File "./ctftool", line 140, in add_challenge
    chal = Challenge.create(**yaml.load(f))
  File "/usr/lib/python3.6/site-packages/peewee.py", line 4915, in create
    inst.save(force_insert=True)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 5108, in save
    pk_from_cursor = self.insert(**field_dict).execute()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3526, in execute
    cursor = self._execute()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 2912, in _execute
    return self.database.execute_sql(sql, params, self.require_commit)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3775, in execute_sql
    self.commit()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3598, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 135, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
peewee.OperationalError: no such table: challenge

Am I missing something?

@jamiees2
Copy link
Member

Have you run ./ctftool database create-tables?

@noraj
Copy link
Contributor Author

noraj commented Sep 25, 2017

Added to the README : #23

@noraj
Copy link
Contributor Author

noraj commented Sep 25, 2017

But now:

./ctftool challenges add problem.yml
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.IntegrityError: NOT NULL constraint failed: challenge.flag

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./ctftool", line 248, in <module>
    main()
  File "./ctftool", line 244, in main
    args.func(args)
  File "./ctftool", line 140, in add_challenge
    chal = Challenge.create(**yaml.load(f))
  File "/usr/lib/python3.6/site-packages/peewee.py", line 4915, in create
    inst.save(force_insert=True)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 5108, in save
    pk_from_cursor = self.insert(**field_dict).execute()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3526, in execute
    cursor = self._execute()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 2912, in _execute
    return self.database.execute_sql(sql, params, self.require_commit)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3775, in execute_sql
    self.commit()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3598, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 135, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
peewee.IntegrityError: NOT NULL constraint failed: challenge.flag

@jamiees2
Copy link
Member

sounds like you made a problem with an empty flag :(

@jamiees2
Copy link
Member

Ah, the sample problem.yml should be flag: not flags:

@noraj
Copy link
Contributor Author

noraj commented Sep 27, 2017

#26

@noraj
Copy link
Contributor Author

noraj commented Sep 27, 2017

@jamiees2

I changed flags: to flag: and that doesn't seem enough

$ ./ctftool challenges add problem.yml                                                                                                                                            shark@dev
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.IntegrityError: NOT NULL constraint failed: challenge.stage_id

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./ctftool", line 248, in <module>
    main()
  File "./ctftool", line 244, in main
    args.func(args)
  File "./ctftool", line 140, in add_challenge
    chal = Challenge.create(**yaml.load(f))
  File "/usr/lib/python3.6/site-packages/peewee.py", line 4915, in create
    inst.save(force_insert=True)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 5108, in save
    pk_from_cursor = self.insert(**field_dict).execute()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3526, in execute
    cursor = self._execute()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 2912, in _execute
    return self.database.execute_sql(sql, params, self.require_commit)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3775, in execute_sql
    self.commit()
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3598, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 135, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
peewee.IntegrityError: NOT NULL constraint failed: challenge.stage_id

@jamiees2
Copy link
Member

Ok yes, so the problem there is that we added stages to the platform, which allow you to group problems together in a group, for example for a beginner stage.

You need to create a stage.yml like this:

name: Test stage
alias: test
description: 

and then add at the end of problem.yml

stage: test

@jamiees2
Copy link
Member

jamiees2 commented Sep 27, 2017

stage.yml can be in the same folder as the problem.yml or in the above structure, for IceCTF 2016 we used the following structure:

stages/
  stage1/
    stage.yml
    problem1/
      problem.yml
      ....
    problem2/
      problem.yml
      ....
  stage2/
    stage.yml
    ....

Then run ./ctftool challenges scan stages

@jamiees2
Copy link
Member

I apologize for the bad docs, this was all done in a bit of a hurry.

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

2 participants