Skip to content

Commit bce8176

Browse files
committed
管理系统增加XSS和SQL注入攻击防御
1 parent 005e25c commit bce8176

22 files changed

+15277
-1
lines changed

internal/ttlcache/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ttlcache
22

3-
import "github.com/cespare/xxhash"
3+
import "github.com/cespare/xxhash/v2"
44

55
func HashKey(key []byte) uint64 {
66
return xxhash.Sum64(key)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Copyright (c) 2012-2016, Nick Galbreath
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
8+
1. Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
https://github.com/client9/libinjection
32+
http://opensource.org/licenses/BSD-3-Clause
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
copy from https://github.com/libinjection/libinjection
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright 2012-2016 Nick Galbreath
3+
4+
* BSD License -- see COPYING.txt for details
5+
*
6+
* https://libinjection.client9.com/
7+
*
8+
*/
9+
10+
#ifndef LIBINJECTION_H
11+
#define LIBINJECTION_H
12+
13+
#ifdef __cplusplus
14+
# define LIBINJECTION_BEGIN_DECLS extern "C" {
15+
# define LIBINJECTION_END_DECLS }
16+
#else
17+
# define LIBINJECTION_BEGIN_DECLS
18+
# define LIBINJECTION_END_DECLS
19+
#endif
20+
21+
LIBINJECTION_BEGIN_DECLS
22+
23+
/*
24+
* Pull in size_t
25+
*/
26+
#include <string.h>
27+
28+
/*
29+
* Version info.
30+
*
31+
* This is moved into a function to allow SWIG and other auto-generated
32+
* binding to not be modified during minor release changes. We change
33+
* change the version number in the c source file, and not regenerated
34+
* the binding
35+
*
36+
* See python's normalized version
37+
* http://www.python.org/dev/peps/pep-0386/#normalizedversion
38+
*/
39+
const char* libinjection_version(void);
40+
41+
/**
42+
* Simple API for SQLi detection - returns a SQLi fingerprint or NULL
43+
* is benign input
44+
*
45+
* \param[in] s input string, may contain nulls, does not need to be null-terminated
46+
* \param[in] slen input string length
47+
* \param[out] fingerprint buffer of 8+ characters. c-string,
48+
* \return 1 if SQLi, 0 if benign. fingerprint will be set or set to empty string.
49+
*/
50+
int libinjection_sqli(const char* s, size_t slen, char fingerprint[]);
51+
52+
/** ALPHA version of xss detector.
53+
*
54+
* NOT DONE.
55+
*
56+
* \param[in] s input string, may contain nulls, does not need to be null-terminated
57+
* \param[in] slen input string length
58+
* \return 1 if XSS found, 0 if benign
59+
*
60+
*/
61+
int libinjection_xss(const char* s, size_t slen, int strictMode);
62+
63+
LIBINJECTION_END_DECLS
64+
65+
#endif /* LIBINJECTION_H */

0 commit comments

Comments
 (0)