Skip to content

Commit 180c875

Browse files
committed
update field1
1 parent 20e4b4d commit 180c875

File tree

10 files changed

+161
-34
lines changed

10 files changed

+161
-34
lines changed
Binary file not shown.

eclipse-projects/FieldAndObjectSensitivity/FieldAndObjectSensitivity_FieldFlowSensitivity1/AndroidManifest.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,27 @@
88
android:minSdkVersion="21"
99
android:targetSdkVersion="21" />
1010

11-
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
11+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
12+
1213
<application
1314
android:allowBackup="true"
1415
android:icon="@drawable/ic_launcher"
1516
android:label="@string/app_name"
1617
android:theme="@style/AppTheme" >
1718
<activity
18-
android:name="com.ksu.fieldFlowSentivity.MainActivity"
19+
android:name=".MainActivity"
1920
android:label="@string/app_name" >
2021
<intent-filter>
2122
<action android:name="android.intent.action.MAIN" />
2223

2324
<category android:name="android.intent.category.LAUNCHER" />
2425
</intent-filter>
2526
</activity>
27+
<activity
28+
android:name=".FooActivity"
29+
android:label="@string/title_activity_foo"
30+
android:exported="false" >
31+
</activity>
2632
</application>
2733

2834
</manifest>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:paddingBottom="@dimen/activity_vertical_margin"
6+
android:paddingLeft="@dimen/activity_horizontal_margin"
7+
android:paddingRight="@dimen/activity_horizontal_margin"
8+
android:paddingTop="@dimen/activity_vertical_margin"
9+
tools:context="com.ksu.fieldFlowSentivity.FooActivity" >
10+
11+
<TextView
12+
android:layout_width="wrap_content"
13+
android:layout_height="wrap_content"
14+
android:text="@string/title_activity_foo" />
15+
16+
</RelativeLayout>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
tools:context="com.ksu.fieldFlowSentivity.FooActivity" >
4+
5+
<item
6+
android:id="@+id/action_settings"
7+
android:orderInCategory="100"
8+
android:showAsAction="never"
9+
android:title="@string/action_settings"/>
10+
11+
</menu>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<resources>
2+
3+
<!--
4+
Example customization of dimensions originally defined in res/values/dimens.xml
5+
(such as screen margins) for screens with more than 820dp of available width. This
6+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
7+
-->
8+
<dimen name="activity_horizontal_margin">64dp</dimen>
9+
10+
</resources>

eclipse-projects/FieldAndObjectSensitivity/FieldAndObjectSensitivity_FieldFlowSensitivity1/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
<string name="app_name">FieldAndObjectSensitivity_FieldFlowSensitivity1</string>
55
<string name="action_settings">Settings</string>
66
<string name="hello_world">Hello world!</string>
7+
<string name="title_activity_foo">FooActivity</string>
78

89
</resources>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,58 @@
11
package com.ksu.fieldFlowSentivity;
22

3-
import android.content.Context;
3+
import android.os.Parcel;
4+
import android.os.Parcelable;
45

5-
public class Data {
6-
public String retrieveData(Context context){
7-
return "Data";
8-
}
6+
public class Data implements Parcelable {
7+
8+
public Data() {
9+
10+
}
11+
12+
private String mData1;
13+
private String mData2;
14+
15+
public void setData1(String d) {
16+
this.mData1 = d;
17+
}
18+
19+
public void setData2(String d) {
20+
this.mData2 = d;
21+
}
22+
23+
public String retrieveData1(){
24+
return this.mData1;
25+
}
26+
27+
public String retrieveData2(){
28+
return this.mData2;
29+
}
30+
31+
@Override
32+
public int describeContents() {
33+
return 0;
34+
}
35+
36+
@Override
37+
public void writeToParcel(Parcel dest, int flags) {
38+
dest.writeString(this.mData1);
39+
dest.writeString(this.mData2);
40+
}
41+
42+
// this is used to regenerate your object. All Parcelables must have a CREATOR that implements these two methods
43+
public static final Parcelable.Creator<Data> CREATOR = new Parcelable.Creator<Data>() {
44+
public Data createFromParcel(Parcel in) {
45+
return new Data(in);
46+
}
47+
48+
public Data[] newArray(int size) {
49+
return new Data[size];
50+
}
51+
};
52+
53+
// example constructor that takes a Parcel and gives you an object populated with it's values
54+
private Data(Parcel in) {
55+
mData1 = in.readString();
56+
mData2 = in.readString();
57+
}
958
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.ksu.fieldFlowSentivity;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.os.Bundle;
6+
import android.util.Log;
7+
import android.view.Menu;
8+
import android.view.MenuItem;
9+
10+
public class FooActivity extends Activity {
11+
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
super.onCreate(savedInstanceState);
15+
setContentView(R.layout.activity_foo);
16+
Intent i = getIntent();
17+
Data d = i.getParcelableExtra("data");
18+
String data1 = d.retrieveData1();
19+
Log.i("data1", data1); // no leak
20+
String data2 = d.retrieveData2();
21+
process(data2);
22+
}
23+
24+
public void process(String data){
25+
// do something. no leak
26+
}
27+
28+
@Override
29+
public boolean onCreateOptionsMenu(Menu menu) {
30+
// Inflate the menu; this adds items to the action bar if it is present.
31+
getMenuInflater().inflate(R.menu.foo, menu);
32+
return true;
33+
}
34+
35+
@Override
36+
public boolean onOptionsItemSelected(MenuItem item) {
37+
// Handle action bar item clicks here. The action bar will
38+
// automatically handle clicks on the Home/Up button, so long
39+
// as you specify a parent activity in AndroidManifest.xml.
40+
int id = item.getItemId();
41+
if (id == R.id.action_settings) {
42+
return true;
43+
}
44+
return super.onOptionsItemSelected(item);
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
package com.ksu.fieldFlowSentivity;
22

33
import android.os.Bundle;
4-
import android.util.Log;
4+
import android.telephony.TelephonyManager;
55
import android.app.Activity;
6+
import android.content.Context;
7+
import android.content.Intent;
68

79
/**
810
* @testcase_name FieldAndObjectSensitivity_FieldFlowSensitivity1
911
* @author Fengguo Wei & Sankardas Roy
1012
* @author_mail fgwei@ksu.edu & sroy@ksu.edu
1113
*
12-
* @description Normal data reterived from Data object and log it. Then, reterive
13-
* sensitive data from SensitiveData, and do some process.
14+
* @description Normal data reterived from Data object and log it (in FooActivity). Then, reterive
15+
* sensitive data from Data, and do some process (no leak, in FooActivity).
1416
* @dataflow source -> _
1517
* @number_of_leaks 0
16-
* @challenges The analysis have to build interprocedural control flow graph in a flow sensitive way.
18+
* @challenges The analysis have to build intercomponent control flow graph in a flow sensitive way.
1719
*/
1820
public class MainActivity extends Activity {
19-
20-
Data data;
21+
2122
@Override
2223
protected void onCreate(Bundle savedInstanceState) {
2324
super.onCreate(savedInstanceState);
2425
Data d = new Data();
25-
this.data = d;
26-
Log.d("id", this.data.retrieveData(this)); //sink, no leak
27-
Data sd = new SensitiveData();
28-
this.data = sd;
29-
process(this.data.retrieveData(this));
26+
d.setData1("data");
27+
TelephonyManager tel = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
28+
String imei = tel.getDeviceId(); //source
29+
d.setData2(imei);
30+
Intent i = new Intent(getApplicationContext(), FooActivity.class);
31+
i.putExtra("data", d);
32+
startActivity(i);
3033
}
3134

32-
public void process(String data){
33-
// do something. no leak
34-
}
35+
3536
}

eclipse-projects/FieldAndObjectSensitivity/FieldAndObjectSensitivity_FieldFlowSensitivity1/src/com/ksu/fieldFlowSentivity/SensitiveData.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)