-
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.
Email HTML Injection detection in IAST Java (#3906)
Co-authored-by: Mario Vidal Domínguez <[email protected]>
- Loading branch information
1 parent
6b9449a
commit 473c7e5
Showing
16 changed files
with
337 additions
and
3 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
31 changes: 31 additions & 0 deletions
31
...r/java/iast-common/src/main/java/com/datadoghq/system_tests/iast/utils/EmailExamples.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,31 @@ | ||
package com.datadoghq.system_tests.iast.utils; | ||
|
||
import com.datadoghq.system_tests.iast.utils.mock.MockTransport; | ||
|
||
import javax.mail.Message; | ||
import javax.mail.MessagingException; | ||
import javax.mail.Session; | ||
import javax.mail.Provider; | ||
import javax.mail.internet.InternetAddress; | ||
import javax.mail.internet.MimeMessage; | ||
import java.util.Properties; | ||
|
||
|
||
public class EmailExamples { | ||
|
||
public void mail(final String emailContent) throws MessagingException { | ||
Session session = Session.getDefaultInstance(new Properties()); | ||
Provider provider = | ||
new Provider( | ||
Provider.Type.TRANSPORT, "smtp", MockTransport.class.getName(), "MockTransport", "1.0"); | ||
session.setProvider(provider); | ||
Message email = new MimeMessage(session); | ||
email.setContent(emailContent, "text/html"); | ||
email.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]")); | ||
|
||
MockTransport.send(email); | ||
|
||
} | ||
|
||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...a/iast-common/src/main/java/com/datadoghq/system_tests/iast/utils/mock/MockTransport.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,26 @@ | ||
package com.datadoghq.system_tests.iast.utils.mock; | ||
import javax.mail.Message; | ||
import javax.mail.MessagingException; | ||
import javax.mail.Session; | ||
import javax.mail.Transport; | ||
import javax.mail.URLName; | ||
import javax.mail.Address; | ||
|
||
public class MockTransport extends Transport { | ||
public MockTransport(Session session, URLName urlname) { | ||
super(session, urlname); | ||
} | ||
|
||
public void sendMessage(Message msg, Address[] addresses) throws MessagingException { | ||
this.notifyTransportListeners(1, addresses, new Address[0], new Address[0], msg); | ||
|
||
} | ||
|
||
@Override | ||
public void connect() { | ||
this.setConnected(true); | ||
this.notifyConnectionListeners(1); | ||
} | ||
|
||
public synchronized void connect(String host, int port, String user, String password) {} | ||
} |
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
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
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.