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

JS plugin crashes gateway when jsvm is disabled #1924

Closed
ilijabojanovic opened this issue Oct 1, 2018 · 0 comments
Closed

JS plugin crashes gateway when jsvm is disabled #1924

ilijabojanovic opened this issue Oct 1, 2018 · 0 comments
Assignees
Labels
Milestone

Comments

@ilijabojanovic
Copy link
Member

Do you want to request a feature or report a bug?
BUG
What is the current behavior?
When we set "enable_jsvm": false and start gateway with js bundle, gateway panics
What is the expected behavior?
Gateway should not panic and crash
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

  1. In tyk.conf set "enable_jsvm": false
  2. Start gateway
  3. Add api with js bundle
  4. Save api

Actual:
After gateway reload, gateway panics and crashes

[Oct  1 22:37:46]  INFO main: ----> Using bundle: bundle-js.zip
[Oct  1 22:37:46]  INFO jsvm: Loading JS File: middleware/bundles/4138358cc81148a871b1cc8d56338feb_318b2e1ed433e0195c272c8787f94a5f/sample.js
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x17c4ce9]

goroutine 3272281 [running]:
main.(*JSVM).LoadJSPaths(0xc422e35278, 0xc4202f61a0, 0x1, 0x1, 0xc42067d440, 0x54)
	/Users/ilijabojanovic/work/src/github.com/TykTechnologies/tyk/mw_js_plugin.go:377 +0x3f9
main.processSpec(0xc422e35200, 0xc4206c2cf0, 0x1c11100, 0xc422bf78e0, 0x1c11100, 0xc422bf7900, 0x1c11100, 0xc422bf7920, 0x1c11000, 0xc4206caa80, ...)
	/Users/ilijabojanovic/work/src/github.com/TykTechnologies/tyk/api_loader.go:225 +0x636f
main.loadApps.func3(0xc4206c2fc0, 0xc4204aa350, 0xc4206c2cf0, 0x1a4ae9b, 0x7, 0x1, 0x1a4b7ee, 0x7, 0xc4206c0000, 0x1a4e42b, ...)
	/Users/ilijabojanovic/work/src/github.com/TykTechnologies/tyk/api_loader.go:574 +0x280
created by main.loadApps
	/Users/ilijabojanovic/work/src/github.com/TykTechnologies/tyk/api_loader.go:564 +0xbb9

Here is testing api definition:

{
    "id": "5bab7ea8cce9f316252d7976",
    "name": "api2",
    "slug": "api2",
    "api_id": "4138358cc81148a871b1cc8d56338feb",
    "org_id": "5ba8b8d09b7d7c23de36eeac",
    "use_keyless": false,
    "use_oauth2": false,
    "use_openid": false,
    "openid_options": {
        "providers": [],
        "segregate_by_client": false
    },
    "oauth_meta": {
        "allowed_access_types": [],
        "allowed_authorize_types": [],
        "auth_login_redirect": ""
    },
    "auth": {
        "use_param": false,
        "param_name": "",
        "use_cookie": false,
        "cookie_name": "",
        "auth_header_name": "Authorization",
        "use_certificate": false
    },
    "use_basic_auth": false,
    "basic_auth": {
        "disable_caching": false,
        "cache_ttl": 0
    },
    "use_mutual_tls_auth": false,
    "client_certificates": [],
    "upstream_certificates": {},
    "pinned_public_keys": {},
    "enable_jwt": false,
    "use_standard_auth": true,
    "enable_coprocess_auth": false,
    "jwt_signing_method": "",
    "jwt_source": "",
    "jwt_identity_base_field": "",
    "jwt_client_base_field": "",
    "jwt_policy_field_name": "",
    "jwt_disable_issued_at_validation": false,
    "jwt_disable_expires_at_validation": false,
    "jwt_disable_not_before_validation": false,
    "jwt_skip_kid": false,
    "notifications": {
        "shared_secret": "",
        "oauth_on_keychange_url": ""
    },
    "enable_signature_checking": false,
    "hmac_allowed_clock_skew": -1,
    "base_identity_provided_by": "",
    "definition": {
        "location": "header",
        "key": "x-api-version",
        "strip_path": false
    },
    "version_data": {
        "not_versioned": true,
        "default_version": "",
        "versions": {
            "Default": {
                "name": "Default",
                "expires": "",
                "paths": {
                    "ignored": [],
                    "white_list": [],
                    "black_list": []
                },
                "use_extended_paths": true,
                "extended_paths": {},
                "global_headers": {},
                "global_headers_remove": [],
                "global_size_limit": 0,
                "override_target": ""
            }
        }
    },
    "uptime_tests": {
        "check_list": [],
        "config": {
            "expire_utime_after": 0,
            "service_discovery": {
                "use_discovery_service": false,
                "query_endpoint": "",
                "use_nested_query": false,
                "parent_data_path": "",
                "data_path": "",
                "port_data_path": "",
                "target_path": "",
                "use_target_list": false,
                "cache_timeout": 60,
                "endpoint_returns_list": false
            },
            "recheck_wait": 0
        }
    },
    "proxy": {
        "preserve_host_header": false,
        "listen_path": "/api2/",
        "target_url": "http://httpbin.org/",
        "strip_listen_path": true,
        "enable_load_balancing": false,
        "target_list": [],
        "check_host_against_uptime_tests": false,
        "service_discovery": {
            "use_discovery_service": false,
            "query_endpoint": "",
            "use_nested_query": false,
            "parent_data_path": "",
            "data_path": "",
            "port_data_path": "",
            "target_path": "",
            "use_target_list": false,
            "cache_timeout": 0,
            "endpoint_returns_list": false
        },
        "transport": {
            "ssl_ciphers": [],
            "ssl_min_version": 0,
            "proxy_url": ""
        }
    },
    "disable_rate_limit": false,
    "disable_quota": false,
    "custom_middleware": {
        "pre": [],
        "post": [],
        "post_key_auth": [],
        "auth_check": {
            "name": "",
            "path": "",
            "require_session": false
        },
        "response": [],
        "driver": "",
        "id_extractor": {
            "extract_from": "",
            "extract_with": "",
            "extractor_config": {}
        }
    },
    "custom_middleware_bundle": "bundle-js.zip",
    "cache_options": {
        "cache_timeout": 60,
        "enable_cache": true,
        "cache_all_safe_requests": false,
        "cache_response_codes": [],
        "enable_upstream_cache_control": false,
        "cache_control_ttl_header": ""
    },
    "session_lifetime": 0,
    "active": true,
    "auth_provider": {
        "name": "",
        "storage_engine": "",
        "meta": {}
    },
    "session_provider": {
        "name": "",
        "storage_engine": "",
        "meta": {}
    },
    "event_handlers": {
        "events": {}
    },
    "enable_batch_request_support": false,
    "enable_ip_whitelisting": false,
    "allowed_ips": [],
    "enable_ip_blacklisting": false,
    "blacklisted_ips": [],
    "dont_set_quota_on_create": false,
    "expire_analytics_after": 0,
    "response_processors": [],
    "CORS": {
        "enable": false,
        "allowed_origins": [],
        "allowed_methods": [],
        "allowed_headers": [],
        "exposed_headers": [],
        "allow_credentials": false,
        "max_age": 24,
        "options_passthrough": false,
        "debug": false
    },
    "domain": "",
    "do_not_track": false,
    "tags": [],
    "enable_context_vars": false,
    "config_data": {},
    "tag_headers": [],
    "global_rate_limit": {
        "rate": 0,
        "per": 0
    },
    "strip_auth_data": false
}

bundle-js.zip

Which versions of Tyk affected by this issue? Did this work in previous versions of Tyk?
Issue is introduced in 2.7.1 release on 2.7.0 this issue isn't visible

@ilijabojanovic ilijabojanovic changed the title JS plugins crashes gateway when jsvm is disabled JS plugin crashes gateway when jsvm is disabled Oct 1, 2018
buger added a commit that referenced this issue Oct 2, 2018
Should check if JSVM enabled before loading JS files
@buger buger closed this as completed in c0b351b Oct 2, 2018
buger added a commit that referenced this issue Oct 2, 2018
Should check if JSVM enabled before loading JS files
@buger buger mentioned this issue Oct 2, 2018
@ilijabojanovic ilijabojanovic added this to the Release 2.7.x milestone Oct 2, 2018
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

3 participants