Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
7dbfea87
Commit
7dbfea87
authored
Apr 04, 2019
by
sikang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://47.100.14.92:8929/sikang/lib_base
update .
parents
947f3ad3
dee00c36
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
24 deletions
+28
-24
script/garble/insert.py
+28
-23
script/module_push.sh
+0
-1
No files found.
script/garble/insert.py
View file @
7dbfea87
...
...
@@ -27,36 +27,42 @@ def get_rand_code(isInFunc):
# 随机缩进
num
=
random
.
randint
(
0
,
4
);
code
=
";
\n
"
filedName
=
gen_rand_str
()
filed_name
=
gen_rand_str
()
filed_value
=
random
.
randint
(
0
,
100000
);
# 随机代码
if
num
==
0
:
code
+=
indentasiStr
+
"String "
+
filed
N
ame
+
"=
\"
"
+
gen_rand_str
()
+
"
\"
;
\n
"
code
+=
indentasiStr
+
"String "
+
filed
_n
ame
+
"=
\"
"
+
gen_rand_str
()
+
"
\"
;
\n
"
elif
num
==
1
:
code
+=
indentasiStr
+
"int "
+
filed
Name
+
"="
+
str
(
random
.
randint
(
0
,
100000
)
)
+
";
\n
"
code
+=
indentasiStr
+
"int "
+
filed
_name
+
"="
+
str
(
filed_value
)
+
";
\n
"
elif
num
==
2
:
code
+=
indentasiStr
+
"float "
+
filed
Name
+
"="
+
str
(
random
.
randint
(
0
,
100000
)
)
+
";
\n
"
code
+=
indentasiStr
+
"float "
+
filed
_name
+
"="
+
str
(
filed_value
)
+
";
\n
"
elif
num
==
3
:
code
+=
indentasiStr
+
"double "
+
filed
Name
+
"="
+
str
(
random
.
randint
(
0
,
100000
)
)
+
";
\n
"
code
+=
indentasiStr
+
"double "
+
filed
_name
+
"="
+
str
(
filed_value
)
+
";
\n
"
elif
num
==
4
:
code
+=
indentasiStr
+
"long "
+
filed
Name
+
"="
+
str
(
random
.
randint
(
0
,
100000
)
)
+
";
\n
"
code
+=
indentasiStr
+
"long "
+
filed
_name
+
"="
+
str
(
filed_value
)
+
";
\n
"
if
isInFunc
:
if
num
==
0
:
code
+=
"if(
\"
"
+
filed
N
ame
+
"
\"
.equals(
\"
"
+
gen_rand_str
()
+
"
\"
)){}//interference code
\n
"
code
+=
"if(
\"
"
+
filed
_n
ame
+
"
\"
.equals(
\"
"
+
gen_rand_str
()
+
"
\"
)){}//interference code
\n
"
else
:
index
=
gen_rand_str
()
code
+=
"for(int "
+
index
+
"="
+
str
(
random
.
randint
(
0
,
10
))
+
";"
+
index
+
"<"
+
filedName
+
";"
+
index
+
"++){}//interference code
\n
"
if
random
.
randint
(
0
,
10
)
%
2
==
0
:
code
+=
"while("
+
filed_name
+
"++<"
+
str
(
filed_value
)
+
"+1){}"
else
:
index
=
gen_rand_str
()
code
+=
"for(int "
+
index
+
"="
+
str
(
filed_value
+
1
)
+
";"
+
index
+
"<"
+
filed_name
+
";"
+
index
+
"++){}//interference code
\n
"
return
code
def
get_brackets
(
line
):
left
=
line
.
count
(
"{"
)
right
=
line
.
count
(
"}"
)
return
left
-
right
def
is_note
(
line
):
final_line
=
line
.
replace
(
"://"
,
""
)
return
"//"
in
final_line
or
"
\t
*"
in
final_line
final_line
=
line
.
replace
(
"://"
,
""
)
return
"//"
in
final_line
or
"
\t
*"
in
final_line
def
process_file_content
(
path
,
file_name
):
...
...
@@ -72,17 +78,17 @@ def process_file_content(path, file_name):
func_level
=
0
isAbstract
=
False
for
line
in
lines
:
#接口和抽象类 直接跳过
#
接口和抽象类 直接跳过
if
"interface"
in
line
or
"abstract"
in
line
:
isAbstract
=
True
isAbstract
=
True
if
isAbstract
or
is_note
(
line
):
f_w
.
write
(
line
)
continue
#没加{}的if else
#
没加{}的if else
if
(
"if("
in
line
or
"if ("
in
line
)
and
"{"
not
in
line
:
isErrorIf
=
True
#return后有多行代码
#
return后有多行代码
if
"return"
in
line
or
(
"throw"
in
line
and
not
isReturn
):
isReturn
=
True
return_level
=
get_brackets
(
line
)
...
...
@@ -93,20 +99,19 @@ def process_file_content(path, file_name):
return_level
=
0
if
" class "
in
line
and
"{"
in
line
:
func_level
=
0
func_level
=
0
if
(
"){
\n
"
in
line
or
") {
\n
"
in
line
)
and
func_level
==
0
and
not
isReturn
:
func_level
=
get_brackets
(
line
)
elif
func_level
!=
0
:
if
"new "
in
line
and
"{"
in
line
:
if
"new "
in
line
and
"{"
in
line
:
func_level
=
0
else
:
func_level
+=
get_brackets
(
line
)
if
func_level
<
0
:
func_level
+=
get_brackets
(
line
)
if
func_level
<
0
:
func_level
=
0
#需要忽略的行
# 需要忽略的行
if
not
isReturn
and
not
isErrorIf
and
\
";
\n
"
in
line
and
\
"return"
not
in
line
and
\
...
...
@@ -120,9 +125,9 @@ def process_file_content(path, file_name):
not
is_note
(
line
):
if
random
.
randint
(
0
,
20
)
%
2
==
0
:
line
=
line
.
replace
(
";
\n
"
,
get_rand_code
(
func_level
>
0
))
line
=
line
.
replace
(
";
\n
"
,
get_rand_code
(
func_level
>
0
))
if
";"
in
line
:
if
";"
in
line
:
isErrorIf
=
False
if
";
\n
"
in
line
and
return_level
==
0
:
...
...
script/module_push.sh
View file @
7dbfea87
...
...
@@ -4,7 +4,6 @@ read message
if
((
${#
message
}
==
0
))
then
echo
"message can not be null !"
cd
script
./module_push.sh
else
cd
../../
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment