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

Error when importing from DefectDojo #51

Closed
luminescence69 opened this issue Jun 16, 2022 · 5 comments
Closed

Error when importing from DefectDojo #51

luminescence69 opened this issue Jun 16, 2022 · 5 comments

Comments

@luminescence69
Copy link

I'm seeing "filter" error when trying to import findings from DefectDojo

Environment:

Request Method: GET
Request URL: http://127.0.0.1/findings/defectdojo/products/2

Django Version: 3.2.5
Python Version: 3.8.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'martor',
'django_bleach',
'preport']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']

Template error:
In template /opt/petereport/app/preport/templates/findings/defectdojo_products.html, error at line 20
Invalid filter: 'bleach'
10 :
11 :


12 :

13 :

14 :

15 :

Import DefectDojo Findings into {{DB_report_query.title}}


16 :

17 :
24 :

25 :
DefectDojo: {{DefectDojoURL}}

26 :

27 :
28 :

29 :
30 :

Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.8/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/opt/petereport/app/preport/decorators.py", line 15, in wrapper_func
return view_func(request, *args, **kwargs)
File "/opt/petereport/app/preport/views.py", line 1324, in defectdojo_products
return render(request, 'findings/defectdojo_products.html', {'DB_report_query': DB_report_query, 'DDproducts_count': DDproducts_count, 'DDproducts': DDproducts, 'DefectDojoURL': DefectDojoURL})
File "/usr/local/lib/python3.8/dist-packages/django/shortcuts.py", line 19, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "/usr/local/lib/python3.8/dist-packages/django/template/loader.py", line 61, in render_to_string
template = get_template(template_name, using=using)
File "/usr/local/lib/python3.8/dist-packages/django/template/loader.py", line 15, in get_template
return engine.get_template(template_name)
File "/usr/local/lib/python3.8/dist-packages/django/template/backends/django.py", line 34, in get_template
return Template(self.engine.get_template(template_name), self)
File "/usr/local/lib/python3.8/dist-packages/django/template/engine.py", line 143, in get_template
template, origin = self.find_template(template_name)
File "/usr/local/lib/python3.8/dist-packages/django/template/engine.py", line 125, in find_template
template = loader.get_template(name, skip=skip)
File "/usr/local/lib/python3.8/dist-packages/django/template/loaders/base.py", line 29, in get_template
return Template(
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 155, in init
self.nodelist = self.compile_nodelist()
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 193, in compile_nodelist
return parser.parse()
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 478, in parse
raise self.error(token, e)
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 476, in parse
compiled_result = compile_func(self, token)
File "/usr/local/lib/python3.8/dist-packages/django/template/loader_tags.py", line 278, in do_extends
nodelist = parser.parse()
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 478, in parse
raise self.error(token, e)
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 476, in parse
compiled_result = compile_func(self, token)
File "/usr/local/lib/python3.8/dist-packages/django/template/loader_tags.py", line 216, in do_block
nodelist = parser.parse(('endblock',))
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 449, in parse
raise self.error(token, e)
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 447, in parse
filter_expression = self.compile_filter(token.contents)
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 563, in compile_filter
return FilterExpression(token, self)
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 657, in init
filter_func = parser.find_filter(filter_name)
File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 569, in find_filter
raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name)

Exception Type: TemplateSyntaxError at /findings/defectdojo/products/2
Exception Value: Invalid filter: 'bleach'

@1modm
Copy link
Owner

1modm commented Aug 30, 2022

Hi @luminescence69,

Should be fixed, try to update git pull and fetch data from Defectdojo.

Thanks

@1modm 1modm closed this as completed Aug 30, 2022
@tech-surajrk
Copy link

I'm seeing "filter" error when trying to import findings from DefectDojo

Environment:

Request Method: GET Request URL: http://127.0.0.1/findings/defectdojo/products/2

Django Version: 3.2.5 Python Version: 3.8.10 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'martor', 'django_bleach', 'preport'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Template error: In template /opt/petereport/app/preport/templates/findings/defectdojo_products.html, error at line 20 Invalid filter: 'bleach' 10 : 11 :

12 :

13 :

14 :

15 :

Import DefectDojo Findings into {{DB_report_query.title}}

16 :

17 :

18 :

19 :
2. Home

20 :
4. [ {{ DB_report_query.product.name | bleach}} ](/product/view/{{ DB_report_query.product.pk}})

21 :
6. [{{ DB_report_query.title | bleach}}](/report/view/{{ DB_report_query.pk}})

22 :

23 :

24 :

25 :

DefectDojo: {{DefectDojoURL}}

26 :

27 :
28 :

29 :
30 :
Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.8/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view return view_func(request, *args, **kwargs) File "/opt/petereport/app/preport/decorators.py", line 15, in wrapper_func return view_func(request, *args, **kwargs) File "/opt/petereport/app/preport/views.py", line 1324, in defectdojo_products return render(request, 'findings/defectdojo_products.html', {'DB_report_query': DB_report_query, 'DDproducts_count': DDproducts_count, 'DDproducts': DDproducts, 'DefectDojoURL': DefectDojoURL}) File "/usr/local/lib/python3.8/dist-packages/django/shortcuts.py", line 19, in render content = loader.render_to_string(template_name, context, request, using=using) File "/usr/local/lib/python3.8/dist-packages/django/template/loader.py", line 61, in render_to_string template = get_template(template_name, using=using) File "/usr/local/lib/python3.8/dist-packages/django/template/loader.py", line 15, in get_template return engine.get_template(template_name) File "/usr/local/lib/python3.8/dist-packages/django/template/backends/django.py", line 34, in get_template return Template(self.engine.get_template(template_name), self) File "/usr/local/lib/python3.8/dist-packages/django/template/engine.py", line 143, in get_template template, origin = self.find_template(template_name) File "/usr/local/lib/python3.8/dist-packages/django/template/engine.py", line 125, in find_template template = loader.get_template(name, skip=skip) File "/usr/local/lib/python3.8/dist-packages/django/template/loaders/base.py", line 29, in get_template return Template( File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 155, in init self.nodelist = self.compile_nodelist() File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 193, in compile_nodelist return parser.parse() File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 478, in parse raise self.error(token, e) File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 476, in parse compiled_result = compile_func(self, token) File "/usr/local/lib/python3.8/dist-packages/django/template/loader_tags.py", line 278, in do_extends nodelist = parser.parse() File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 478, in parse raise self.error(token, e) File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 476, in parse compiled_result = compile_func(self, token) File "/usr/local/lib/python3.8/dist-packages/django/template/loader_tags.py", line 216, in do_block nodelist = parser.parse(('endblock',)) File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 449, in parse raise self.error(token, e) File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 447, in parse filter_expression = self.compile_filter(token.contents) File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 563, in compile_filter return FilterExpression(token, self) File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 657, in init filter_func = parser.find_filter(filter_name) File "/usr/local/lib/python3.8/dist-packages/django/template/base.py", line 569, in find_filter raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name)

Exception Type: TemplateSyntaxError at /findings/defectdojo/products/2 Exception Value: Invalid filter: 'bleach'

Were you able to import data from DefectDojo through API ?
I am getting data not found error.. Can you help me with the configuration changes ehich you have done ?

@1modm
Copy link
Owner

1modm commented Sep 2, 2022

@surajanuja you can check the changes here: 04b160a

But we can try to check with a Defectdojo demo server, try to configure in petereport_config.py:

DEFECTDOJO_CONFIG = {
	'DefectDojoURL': 'https://demo.defectdojo.org',
	'apiKey': 'Token 548afd6fab3bea9794a41b31da0e9404f733e222' # Format: Token <api_key>
}

Then check if you can import those findings:

image

Check that the API key is correct, it seems to change everyday: https://demo.defectdojo.org/api/key-v2

image

@tech-surajrk
Copy link

@surajanuja you can check the changes here: 04b160a

But we can try to check with a Defectdojo demo server, try to configure in petereport_config.py:

DEFECTDOJO_CONFIG = {
	'DefectDojoURL': 'https://demo.defectdojo.org',
	'apiKey': 'Token 548afd6fab3bea9794a41b31da0e9404f733e222' # Format: Token <api_key>
}

Then check if you can import those findings:

image

Check that the API key is correct, it seems to change everyday: https://demo.defectdojo.org/api/key-v2

image

@1modm - After doing the above mentioned configuration it loads the entire product list from defectdojo but when I click on import findings, it imports all the findings. Is there a way to select specific findings only from a product?

@1modm
Copy link
Owner

1modm commented Jan 18, 2023

@surajanuja thank you for the comment, nope, at the moment is only possible to pull all the findings from the DefectDojo products. I have opened a request to implement this functionality: #64

Thanks

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

3 participants