2
2
package rule
3
3
4
4
import (
5
- "bytes"
6
5
"context"
7
6
"encoding/json"
8
7
"encoding/xml"
@@ -27,9 +26,13 @@ type Rule struct {
27
26
XMLName xml.Name `xml:"Rule"`
28
27
Name string `xml:"name,attr"`
29
28
Type string `xml:"type,attr"`
30
- Description string `xml:"Description,omitempty"`
31
- Signature * Signature
32
- Source string `xml:"Source"`
29
+ Description struct {
30
+ Content string `xml:",innerxml"`
31
+ }
32
+ Signature * Signature
33
+ Source struct {
34
+ Content string `xml:",cdata"`
35
+ } `xml:"Source"`
33
36
}
34
37
35
38
type Signature struct {
@@ -53,7 +56,9 @@ type Argument struct {
53
56
XMLName xml.Name `xml:"Argument"`
54
57
Name string `xml:"name,attr"`
55
58
Type string `xml:"type,attr,omitempty"`
56
- Description string `xml:"Description,omitempty"`
59
+ Description struct {
60
+ Content string `xml:",innerxml"`
61
+ }
57
62
}
58
63
59
64
var cloudRuleTypes = []string {"AttributeGenerator" , "AttributeGeneratorFromTemplate" , "BeforeProvisioning" , "BuildMap" , "Correlation" , "IdentityAttribute" , "ManagerCorrelation" }
@@ -150,12 +155,12 @@ func saveCloudXMLRules(apiClient *sailpoint.APIClient, description string, inclu
150
155
rule .Type = RuleType
151
156
152
157
if v .Object ["description" ] != nil {
153
- rule .Description = v .Object ["description" ].(string )
158
+ rule .Description . Content = v .Object ["description" ].(string )
154
159
} else {
155
- rule .Description = ""
160
+ rule .Description . Content = ""
156
161
}
157
162
158
- rule .Source = "<![CDATA[ \n " + v .Object ["sourceCode" ].(map [string ]interface {})["script" ].(string ) + " \n ]]>"
163
+ rule .Source . Content = v .Object ["sourceCode" ].(map [string ]interface {})["script" ].(string )
159
164
160
165
var ruleSignature = & Signature {}
161
166
@@ -175,9 +180,9 @@ func saveCloudXMLRules(apiClient *sailpoint.APIClient, description string, inclu
175
180
}
176
181
177
182
if v .(map [string ]interface {})["description" ] != nil {
178
- argument .Description = v .(map [string ]interface {})["description" ].(string )
183
+ argument .Description . Content = v .(map [string ]interface {})["description" ].(string )
179
184
} else {
180
- argument .Description = ""
185
+ argument .Description . Content = ""
181
186
}
182
187
183
188
ruleSignature .Inputs .Argument = append (ruleSignature .Inputs .Argument , argument )
@@ -203,9 +208,9 @@ func saveCloudXMLRules(apiClient *sailpoint.APIClient, description string, inclu
203
208
}
204
209
205
210
if v .(map [string ]interface {})["description" ] != nil {
206
- argument .Description = v .(map [string ]interface {})["description" ].(string )
211
+ argument .Description . Content = v .(map [string ]interface {})["description" ].(string )
207
212
} else {
208
- argument .Description = ""
213
+ argument .Description . Content = ""
209
214
}
210
215
211
216
ruleSignature .Returns .Argument = append (ruleSignature .Returns .Argument , argument )
@@ -225,9 +230,9 @@ func saveCloudXMLRules(apiClient *sailpoint.APIClient, description string, inclu
225
230
}
226
231
227
232
if output ["description" ] != nil {
228
- argument .Description = output ["description" ].(string )
233
+ argument .Description . Content = output ["description" ].(string )
229
234
} else {
230
- argument .Description = ""
235
+ argument .Description . Content = ""
231
236
}
232
237
233
238
ruleSignature .Returns .Argument = append (ruleSignature .Returns .Argument , argument )
@@ -238,15 +243,7 @@ func saveCloudXMLRules(apiClient *sailpoint.APIClient, description string, inclu
238
243
239
244
out = []byte (xml .Header + SailPointHeader + string (out ))
240
245
241
- out = bytes .Replace (out , []byte ("
" ), []byte ("\n " ), - 1 )
242
- out = bytes .Replace (out , []byte ("
" ), []byte ("\r " ), - 1 )
243
- out = bytes .Replace (out , []byte (""" ), []byte ("\" " ), - 1 )
244
- out = bytes .Replace (out , []byte ("&" ), []byte ("&" ), - 1 )
245
- out = bytes .Replace (out , []byte ("	" ), []byte ("\t " ), - 1 )
246
- out = bytes .Replace (out , []byte ("<" ), []byte ("<" ), - 1 )
247
- out = bytes .Replace (out , []byte (">" ), []byte (">" ), - 1 )
248
-
249
- err := output .WriteFile (destination + "/cloud" , "Rule - " + rule .Type + " - " + rule .Name + ".xml" , out )
246
+ err = output .WriteFile (destination + "/cloud" , "Rule - " + rule .Type + " - " + rule .Name + ".xml" , out )
250
247
251
248
if err != nil {
252
249
return err
0 commit comments