-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a new feature that allows the application to be configured to send all uploaded content to an external process, a ClamAV daemon, that scans it for malware.
- Loading branch information
Showing
10 changed files
with
303 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/nl/goodbytes/xmpp/xep0363/MalwareDetectedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2023 Guus der Kinderen. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nl.goodbytes.xmpp.xep0363; | ||
|
||
public class MalwareDetectedException extends Exception | ||
{ | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/nl/goodbytes/xmpp/xep0363/MalwareScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2023 Guus der Kinderen. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nl.goodbytes.xmpp.xep0363; | ||
|
||
import java.io.IOException; | ||
|
||
public interface MalwareScanner | ||
{ | ||
void initialize() throws IOException; | ||
|
||
void destroy(); | ||
|
||
void scan(final SecureUniqueId uuid) throws MalwareDetectedException, IOException; | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/nl/goodbytes/xmpp/xep0363/MalwareScannerManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2023 Guus der Kinderen. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nl.goodbytes.xmpp.xep0363; | ||
|
||
import java.io.IOException; | ||
|
||
public class MalwareScannerManager | ||
{ | ||
private static MalwareScannerManager INSTANCE; | ||
|
||
public synchronized static MalwareScannerManager getInstance() | ||
{ | ||
if (INSTANCE == null) { | ||
INSTANCE = new MalwareScannerManager(); | ||
} | ||
|
||
return INSTANCE; | ||
} | ||
|
||
private MalwareScanner malwareScanner; | ||
|
||
public boolean isEnabled() { | ||
return this.malwareScanner != null; | ||
} | ||
|
||
public void initialize(final MalwareScanner malwareScanner) throws IOException | ||
{ | ||
if (this.malwareScanner != null) { | ||
throw new IllegalArgumentException("Already initialized."); | ||
} | ||
this.malwareScanner = malwareScanner; | ||
this.malwareScanner.initialize(); | ||
} | ||
|
||
public MalwareScanner getMalwareScanner() | ||
{ | ||
return this.malwareScanner; | ||
} | ||
|
||
public void destroy() | ||
{ | ||
if (this.malwareScanner != null) { | ||
this.malwareScanner.destroy(); | ||
this.malwareScanner = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.