<filename>Dangerous/Golismero/golismero/api/data/vulnerability/cookie/__init__.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Cookie vulnerabilities.
"""

__license__= """
GoLismero 2.0 - The web knife - Copyright (C) 2011-2014

Golismero project site: https://github.com/golismero
Golismero project mail: <EMAIL>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
"""

__all__ = ["CookieVulnerability"]

from .. import Vulnerability
from ... import identity
from ...information.http import HTTP_Response


#------------------------------------------------------------------------------
class CookieVulnerability(Vulnerability):
    """
    Cookie Vulnerability.

    An unspecified vulnerability has been found in an HTTP cookie.
    """

    # XXX FIXME not sure if it should be this or the URL!
    TARGET_CLASS = HTTP_Response


    #--------------------------------------------------------------------------
    def __init__(self, target, cookie, **kwargs):
        """
        :param target: HTTP response where the vulnerable cookie was found.
        :type target: HTTP_Response

        :param cookie: Name of the vulnerable cookie.
        :type cookie: str
        """

        # Name of the vulnerable cookie.
        if type(cookie) is not str:
            raise TypeError("Expected str, got %r instead" % type(cookie))
        self.__cookie = cookie

        # Parent constructor.
        super(CookieVulnerability, self).__init__(target, **kwargs)

    __init__.__doc__ += Vulnerability.__init__.__doc__[
            Vulnerability.__init__.__doc__.find("\n        :keyword"):]


    #--------------------------------------------------------------------------
    @identity
    def cookie(self):
        """
        :returns: Name of the vulnerable cookie.
        :rtype: str
        """
        return self.__cookie
