Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
public static BigInteger safeInstance(BigInteger val) {
  // create a defensive copy if it is not java.math.BigInteger
  if (val.getClass() != java.math.BigInteger.class)
    return new BigInteger(val.toByteArray());

  return val;
}

The rules "FIO00-J. Defensively copy mutable inputs and mutable internal components" and "OBJ08-J. Provide mutable classes with copy functionality to allow passing instances to untrusted code safely" discuss defensive copying in great depth.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8e098d4d7b2b0bf0-a41477cd-43434424-9af2a70f-e47d47387b15fa85be89df6b"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

Class BigInteger

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="10fc735a54b1495c-b2b36a12-47a2448c-aaf39d1e-5150af100f2bd5dfe65ba936"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 1: "Consider static factory methods instead of constructors"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="990ded4fbfe09942-580b1b09-45634dfc-a5eab067-1d3a36758004eceea3213bbc"><ac:plain-text-body><![CDATA[

[[Gong 2003

AA. Bibliography#Gong 03]]

Chapter 6: "Enforcing Security Policy"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c85d5f4339e82cf6-e934d679-4d38424a-8ac88028-e52a537ad4746e830b313877"><ac:plain-text-body><![CDATA[

[[Lai 2008

AA. Bibliography#Lai 08]]

Java Insecurity: Accounting for Subtleties That Can Compromise Code

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="391d5b018a4b8d10-84f4008a-40b94071-8fbd9654-7a779fc970f341022bee5f25"><ac:plain-text-body><![CDATA[

[[McGraw 1999

AA. Bibliography#McGraw 99]]

Chapter Seven Rule 3: "Make Everything Final, Unless There's a Good Reason Not To"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1376cf0a3f6e6bb7-2bd19297-42054b27-bcaf8839-fd1bc2c43220d39461c06207"><ac:plain-text-body><![CDATA[

[[SCG 2007

AA. Bibliography#SCG 07]]

Guideline 1-2 "Limit the extensibility of classes and methods"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ccfc5b7d2d65bf9c-929c3b31-4dfc426b-a18fb3f5-c2ab583cf949f17b9a25b46a"><ac:plain-text-body><![CDATA[

[[SCG 2009

AA. Bibliography#SCG 09]]

Secure Coding Guidelines for the Java Programming Language, version 3.0

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e850ebdc4db6df5e-71312f96-4e2540d4-a99fbf76-32e5ec6b1fbe4efe249689f3"><ac:plain-text-body><![CDATA[

[[Ware 2008

AA. Bibliography#Ware 08]]

]]></ac:plain-text-body></ac:structured-macro>

...