Skip to content

Commit

Permalink
Merge pull request #459 from lostsnow/feature/project-template
Browse files Browse the repository at this point in the history
add app template property
  • Loading branch information
lostsnow authored Jan 31, 2023
2 parents 8789276 + 643a1f1 commit f12890b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class IastProperties {
put("app_create", PropertyConstant.PROPERTY_APP_CREATE);
put("app_name", PropertyConstant.PROPERTY_APP_NAME);
put("app_version", PropertyConstant.PROPERTY_APP_VERSION);
put("app_template", PropertyConstant.PROPERTY_APP_TEMPLATE);
put("engine_name", PropertyConstant.PROPERTY_ENGINE_NAME);
put("cluster_name", PropertyConstant.PROPERTY_CLUSTER_NAME);
put("cluster_version", PropertyConstant.PROPERTY_CLUSTER_VERSION);
Expand All @@ -39,6 +40,8 @@ public class IastProperties {
private String debugFlag = null;
private Integer isAutoCreateProject;
private String projectName;
private String projectVersion;
private Integer projectTemplate;
private String clusterName;
private String clusterVersion;
private String serverUrl;
Expand All @@ -54,7 +57,6 @@ public class IastProperties {
private String proxyEnableStatus;
private String proxyHost;
private int proxyPort = -1;
private String fallbackVersion;
private String customCoreJarUrl;
private String customSpyJarUrl;
private String customApiJarUrl;
Expand Down Expand Up @@ -162,9 +164,25 @@ public String getProjectName() {
}

public String getProjectVersion() {
return System.getProperty(PropertyConstant.PROPERTY_APP_VERSION,
System.getProperty("project.version", cfg.getProperty("project.version", "V1.0"))
);
if (null == projectVersion) {
projectVersion = System.getProperty(PropertyConstant.PROPERTY_APP_VERSION,
System.getProperty("project.version", cfg.getProperty("project.version", "V1.0"))
);
}
return projectVersion;
}

public Integer getProjectTemplate() {
if (null == projectTemplate) {
try {
projectTemplate = Integer.parseInt(System.getProperty(PropertyConstant.PROPERTY_APP_TEMPLATE,
cfg.getProperty(PropertyConstant.PROPERTY_APP_TEMPLATE, "0"))
);
} catch (NumberFormatException e) {
projectTemplate = 0;
}
}
return projectTemplate;
}

public String getEngineName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private String generateAgentRegisterMsg() {
object.put("serverPort", "");
object.put("autoCreateProject", IastProperties.getInstance().isAutoCreateProject());
object.put("projectVersion", IastProperties.getInstance().getProjectVersion());
object.put("projectTemplateId", IastProperties.getInstance().getProjectTemplate());

return object.toString();
}
Expand Down
3 changes: 2 additions & 1 deletion dongtai-agent/src/main/resources/iast.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ iast.dump.class.path=/tmp/iast-class-dump/
engine.name=java.action.github.com
project.name=ExampleApplication
project.create=
project.version=
project.version=V1.0
dongtai.app.template=0
iast.proxy.enable=false
iast.proxy.host=
iast.proxy.port=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class PropertyConstant {
public static final String PROPERTY_APP_CREATE = "dongtai.app.create";
public static final String PROPERTY_APP_NAME = "dongtai.app.name";
public static final String PROPERTY_APP_VERSION = "dongtai.app.version";
public static final String PROPERTY_APP_TEMPLATE = "dongtai.app.template";
public static final String PROPERTY_ENGINE_NAME = "dongtai.engine.name";
public static final String PROPERTY_CLUSTER_NAME = "dongtai.cluster.name";
public static final String PROPERTY_CLUSTER_VERSION = "dongtai.cluster.version";
Expand Down

0 comments on commit f12890b

Please sign in to comment.